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
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/RelationTestEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class RelationTestEntity { @PrimaryKey
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RelationTestEntity.java import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class RelationTestEntity { @PrimaryKey
@Column(name="ID", type=FieldType.INTEGER)
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/RelationTestEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class RelationTestEntity { @PrimaryKey @Column(name="ID", type=FieldType.INTEGER) private int id;
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RelationTestEntity.java import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class RelationTestEntity { @PrimaryKey @Column(name="ID", type=FieldType.INTEGER) private int id;
@Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestRandomEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE})
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/RelationTestEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class RelationTestEntity { @PrimaryKey @Column(name="ID", type=FieldType.INTEGER) private int id;
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RelationTestEntity.java import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class RelationTestEntity { @PrimaryKey @Column(name="ID", type=FieldType.INTEGER) private int id;
@Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestRandomEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE})
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/criteria/NullBasedRestriction.java
// Path: src/main/java/in/cubestack/android/lib/storm/core/TableInformation.java // public class TableInformation { // // private Class<?> mappedClass; // private int tableVersion; // private String tableName; // private ColumnMetaData primaryKeyData; // private List<ColumnMetaData> columnMetaDataList = new LinkedList<ColumnMetaData>(); // private List<RelationMetaData> relations = new LinkedList<RelationMetaData>(); // private String alias; // private LifeCycleHandler<?> handler; // private String insertSql; // private boolean autoGenerated; // // public String getTableName() { // return tableName; // } // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // // /** // * @return the columnMetaDataList // */ // public List<ColumnMetaData> getColumnMetaDataList() { // return columnMetaDataList; // } // // /** // * @param primaryKeyData // * the primaryKeyData to set // */ // public void setPrimaryKeyData(ColumnMetaData primaryKeyData) { // this.primaryKeyData = primaryKeyData; // } // // /** // * @return the primaryKeyData // */ // public ColumnMetaData getPrimaryKeyData() { // return primaryKeyData; // } // // public int getTableVersion() { // return tableVersion; // } // // public void setTableVersion(int tableVersion) { // this.tableVersion = tableVersion; // } // // @Override // public String toString() { // return "[TableInfo {name=" + tableName + "}, {primaryKey=" + primaryKeyData.getAlias() + "/" + primaryKeyData.getColumnName() + "\n " // + "Mapped class = " + getMappedClass() + "}]"; // } // // public List<RelationMetaData> getRelations() { // return relations; // } // // // public String getAlias() { // return alias; // } // // public void setAlias(String alias) { // this.alias = alias; // } // // public LifeCycleHandler<?> getHandler() { // return handler; // } // // public void setHandler(LifeCycleHandler<?> class1) { // this.handler = class1; // } // // public boolean isRelational() { // return relations != null && !relations.isEmpty(); // } // // public ColumnMetaData getColumnMetaData(String alias) { // // if (getPrimaryKeyData().getAlias().equals(alias)) { // return getPrimaryKeyData(); // } // for (ColumnMetaData columnMetaData : getColumnMetaDataList()) { // if (columnMetaData.getAlias().equals(alias)) { // return columnMetaData; // } // } // return null; // } // // public String getColumnName(String alias) { // ColumnMetaData columnMetaData = getColumnMetaData(alias); // if (columnMetaData != null) { // return columnMetaData.getColumnName(); // } // return null; // } // // public String getProperty(String columnNme) { // if (getPrimaryKeyData().getColumnName().equals(columnNme)) { // return getPrimaryKeyData().getAlias(); // } // for (ColumnMetaData columnMetaData : getColumnMetaDataList()) { // if (columnMetaData.getColumnName().equals(columnNme)) { // return columnMetaData.getAlias(); // } // } // return null; // } // // public String getInsertSql() { // return insertSql; // } // // public void setInsertSql(String insertSql) { // this.insertSql = insertSql; // } // // public boolean isAutoGenerated() { // return autoGenerated; // } // // public void setAutoGenerated(boolean autoGenerated) { // this.autoGenerated = autoGenerated; // } // // public Class<?> getMappedClass() { // return mappedClass; // } // // public void setMappedClass(Class<?> mappedClass) { // this.mappedClass = mappedClass; // } // // }
import in.cubestack.android.lib.storm.core.TableInformation;
package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class NullBasedRestriction extends PageableRestriction { private String property; private boolean isNull;
// Path: src/main/java/in/cubestack/android/lib/storm/core/TableInformation.java // public class TableInformation { // // private Class<?> mappedClass; // private int tableVersion; // private String tableName; // private ColumnMetaData primaryKeyData; // private List<ColumnMetaData> columnMetaDataList = new LinkedList<ColumnMetaData>(); // private List<RelationMetaData> relations = new LinkedList<RelationMetaData>(); // private String alias; // private LifeCycleHandler<?> handler; // private String insertSql; // private boolean autoGenerated; // // public String getTableName() { // return tableName; // } // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // // /** // * @return the columnMetaDataList // */ // public List<ColumnMetaData> getColumnMetaDataList() { // return columnMetaDataList; // } // // /** // * @param primaryKeyData // * the primaryKeyData to set // */ // public void setPrimaryKeyData(ColumnMetaData primaryKeyData) { // this.primaryKeyData = primaryKeyData; // } // // /** // * @return the primaryKeyData // */ // public ColumnMetaData getPrimaryKeyData() { // return primaryKeyData; // } // // public int getTableVersion() { // return tableVersion; // } // // public void setTableVersion(int tableVersion) { // this.tableVersion = tableVersion; // } // // @Override // public String toString() { // return "[TableInfo {name=" + tableName + "}, {primaryKey=" + primaryKeyData.getAlias() + "/" + primaryKeyData.getColumnName() + "\n " // + "Mapped class = " + getMappedClass() + "}]"; // } // // public List<RelationMetaData> getRelations() { // return relations; // } // // // public String getAlias() { // return alias; // } // // public void setAlias(String alias) { // this.alias = alias; // } // // public LifeCycleHandler<?> getHandler() { // return handler; // } // // public void setHandler(LifeCycleHandler<?> class1) { // this.handler = class1; // } // // public boolean isRelational() { // return relations != null && !relations.isEmpty(); // } // // public ColumnMetaData getColumnMetaData(String alias) { // // if (getPrimaryKeyData().getAlias().equals(alias)) { // return getPrimaryKeyData(); // } // for (ColumnMetaData columnMetaData : getColumnMetaDataList()) { // if (columnMetaData.getAlias().equals(alias)) { // return columnMetaData; // } // } // return null; // } // // public String getColumnName(String alias) { // ColumnMetaData columnMetaData = getColumnMetaData(alias); // if (columnMetaData != null) { // return columnMetaData.getColumnName(); // } // return null; // } // // public String getProperty(String columnNme) { // if (getPrimaryKeyData().getColumnName().equals(columnNme)) { // return getPrimaryKeyData().getAlias(); // } // for (ColumnMetaData columnMetaData : getColumnMetaDataList()) { // if (columnMetaData.getColumnName().equals(columnNme)) { // return columnMetaData.getAlias(); // } // } // return null; // } // // public String getInsertSql() { // return insertSql; // } // // public void setInsertSql(String insertSql) { // this.insertSql = insertSql; // } // // public boolean isAutoGenerated() { // return autoGenerated; // } // // public void setAutoGenerated(boolean autoGenerated) { // this.autoGenerated = autoGenerated; // } // // public Class<?> getMappedClass() { // return mappedClass; // } // // public void setMappedClass(Class<?> mappedClass) { // this.mappedClass = mappedClass; // } // // } // Path: src/main/java/in/cubestack/android/lib/storm/criteria/NullBasedRestriction.java import in.cubestack.android.lib.storm.core.TableInformation; package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class NullBasedRestriction extends PageableRestriction { private String property; private boolean isNull;
public NullBasedRestriction(String property, boolean isNull, TableInformation tableInformation) {
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/TestAnother.java
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey;
/** * */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="ANOTHER_TAB") public class TestAnother { @PrimaryKey
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestAnother.java import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey; /** * */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="ANOTHER_TAB") public class TestAnother { @PrimaryKey
@Column(name="ID", type = FieldType.LONG, addedVersion = 1)
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import java.util.ArrayList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * Test Entity * * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class TestEntity { @PrimaryKey
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import java.util.ArrayList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * Test Entity * * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class TestEntity { @PrimaryKey
@Column(name="ID", type=FieldType.INTEGER)
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import java.util.ArrayList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * Test Entity * * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class TestEntity { @PrimaryKey @Column(name="ID", type=FieldType.INTEGER) private int id; @Column(name="NAME", type=FieldType.TEXT) private String name; @Column(name="RATE", type=FieldType.DOUBLE) private double rate; @Column(name="PRICE", type=FieldType.REAL) private int price;
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import java.util.ArrayList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * Test Entity * * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class TestEntity { @PrimaryKey @Column(name="ID", type=FieldType.INTEGER) private int id; @Column(name="NAME", type=FieldType.TEXT) private String name; @Column(name="RATE", type=FieldType.DOUBLE) private double rate; @Column(name="PRICE", type=FieldType.REAL) private int price;
@Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestChild.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE})
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import java.util.ArrayList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * Test Entity * * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class TestEntity { @PrimaryKey @Column(name="ID", type=FieldType.INTEGER) private int id; @Column(name="NAME", type=FieldType.TEXT) private String name; @Column(name="RATE", type=FieldType.DOUBLE) private double rate; @Column(name="PRICE", type=FieldType.REAL) private int price;
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import java.util.ArrayList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; import in.cubestack.android.lib.storm.FieldType; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * Test Entity * * @author Supal Dubey * */ @Table(name="TEST_TAB") @LifeCycle(handler=TestHandler.class) public class TestEntity { @PrimaryKey @Column(name="ID", type=FieldType.INTEGER) private int id; @Column(name="NAME", type=FieldType.TEXT) private String name; @Column(name="RATE", type=FieldType.DOUBLE) private double rate; @Column(name="PRICE", type=FieldType.REAL) private int price;
@Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestChild.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE})
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/mapper/RawQueryMapper.java
// Path: src/main/java/in/cubestack/android/lib/storm/core/TableInformation.java // public class TableInformation { // // private Class<?> mappedClass; // private int tableVersion; // private String tableName; // private ColumnMetaData primaryKeyData; // private List<ColumnMetaData> columnMetaDataList = new LinkedList<ColumnMetaData>(); // private List<RelationMetaData> relations = new LinkedList<RelationMetaData>(); // private String alias; // private LifeCycleHandler<?> handler; // private String insertSql; // private boolean autoGenerated; // // public String getTableName() { // return tableName; // } // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // // /** // * @return the columnMetaDataList // */ // public List<ColumnMetaData> getColumnMetaDataList() { // return columnMetaDataList; // } // // /** // * @param primaryKeyData // * the primaryKeyData to set // */ // public void setPrimaryKeyData(ColumnMetaData primaryKeyData) { // this.primaryKeyData = primaryKeyData; // } // // /** // * @return the primaryKeyData // */ // public ColumnMetaData getPrimaryKeyData() { // return primaryKeyData; // } // // public int getTableVersion() { // return tableVersion; // } // // public void setTableVersion(int tableVersion) { // this.tableVersion = tableVersion; // } // // @Override // public String toString() { // return "[TableInfo {name=" + tableName + "}, {primaryKey=" + primaryKeyData.getAlias() + "/" + primaryKeyData.getColumnName() + "\n " // + "Mapped class = " + getMappedClass() + "}]"; // } // // public List<RelationMetaData> getRelations() { // return relations; // } // // // public String getAlias() { // return alias; // } // // public void setAlias(String alias) { // this.alias = alias; // } // // public LifeCycleHandler<?> getHandler() { // return handler; // } // // public void setHandler(LifeCycleHandler<?> class1) { // this.handler = class1; // } // // public boolean isRelational() { // return relations != null && !relations.isEmpty(); // } // // public ColumnMetaData getColumnMetaData(String alias) { // // if (getPrimaryKeyData().getAlias().equals(alias)) { // return getPrimaryKeyData(); // } // for (ColumnMetaData columnMetaData : getColumnMetaDataList()) { // if (columnMetaData.getAlias().equals(alias)) { // return columnMetaData; // } // } // return null; // } // // public String getColumnName(String alias) { // ColumnMetaData columnMetaData = getColumnMetaData(alias); // if (columnMetaData != null) { // return columnMetaData.getColumnName(); // } // return null; // } // // public String getProperty(String columnNme) { // if (getPrimaryKeyData().getColumnName().equals(columnNme)) { // return getPrimaryKeyData().getAlias(); // } // for (ColumnMetaData columnMetaData : getColumnMetaDataList()) { // if (columnMetaData.getColumnName().equals(columnNme)) { // return columnMetaData.getAlias(); // } // } // return null; // } // // public String getInsertSql() { // return insertSql; // } // // public void setInsertSql(String insertSql) { // this.insertSql = insertSql; // } // // public boolean isAutoGenerated() { // return autoGenerated; // } // // public void setAutoGenerated(boolean autoGenerated) { // this.autoGenerated = autoGenerated; // } // // public Class<?> getMappedClass() { // return mappedClass; // } // // public void setMappedClass(Class<?> mappedClass) { // this.mappedClass = mappedClass; // } // // }
import in.cubestack.android.lib.storm.core.TableInformation; import android.database.Cursor;
/** * */ package in.cubestack.android.lib.storm.mapper; /** * @author supal * */ public class RawQueryMapper implements RowMapper<Object[]> { @Override
// Path: src/main/java/in/cubestack/android/lib/storm/core/TableInformation.java // public class TableInformation { // // private Class<?> mappedClass; // private int tableVersion; // private String tableName; // private ColumnMetaData primaryKeyData; // private List<ColumnMetaData> columnMetaDataList = new LinkedList<ColumnMetaData>(); // private List<RelationMetaData> relations = new LinkedList<RelationMetaData>(); // private String alias; // private LifeCycleHandler<?> handler; // private String insertSql; // private boolean autoGenerated; // // public String getTableName() { // return tableName; // } // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // // /** // * @return the columnMetaDataList // */ // public List<ColumnMetaData> getColumnMetaDataList() { // return columnMetaDataList; // } // // /** // * @param primaryKeyData // * the primaryKeyData to set // */ // public void setPrimaryKeyData(ColumnMetaData primaryKeyData) { // this.primaryKeyData = primaryKeyData; // } // // /** // * @return the primaryKeyData // */ // public ColumnMetaData getPrimaryKeyData() { // return primaryKeyData; // } // // public int getTableVersion() { // return tableVersion; // } // // public void setTableVersion(int tableVersion) { // this.tableVersion = tableVersion; // } // // @Override // public String toString() { // return "[TableInfo {name=" + tableName + "}, {primaryKey=" + primaryKeyData.getAlias() + "/" + primaryKeyData.getColumnName() + "\n " // + "Mapped class = " + getMappedClass() + "}]"; // } // // public List<RelationMetaData> getRelations() { // return relations; // } // // // public String getAlias() { // return alias; // } // // public void setAlias(String alias) { // this.alias = alias; // } // // public LifeCycleHandler<?> getHandler() { // return handler; // } // // public void setHandler(LifeCycleHandler<?> class1) { // this.handler = class1; // } // // public boolean isRelational() { // return relations != null && !relations.isEmpty(); // } // // public ColumnMetaData getColumnMetaData(String alias) { // // if (getPrimaryKeyData().getAlias().equals(alias)) { // return getPrimaryKeyData(); // } // for (ColumnMetaData columnMetaData : getColumnMetaDataList()) { // if (columnMetaData.getAlias().equals(alias)) { // return columnMetaData; // } // } // return null; // } // // public String getColumnName(String alias) { // ColumnMetaData columnMetaData = getColumnMetaData(alias); // if (columnMetaData != null) { // return columnMetaData.getColumnName(); // } // return null; // } // // public String getProperty(String columnNme) { // if (getPrimaryKeyData().getColumnName().equals(columnNme)) { // return getPrimaryKeyData().getAlias(); // } // for (ColumnMetaData columnMetaData : getColumnMetaDataList()) { // if (columnMetaData.getColumnName().equals(columnNme)) { // return columnMetaData.getAlias(); // } // } // return null; // } // // public String getInsertSql() { // return insertSql; // } // // public void setInsertSql(String insertSql) { // this.insertSql = insertSql; // } // // public boolean isAutoGenerated() { // return autoGenerated; // } // // public void setAutoGenerated(boolean autoGenerated) { // this.autoGenerated = autoGenerated; // } // // public Class<?> getMappedClass() { // return mappedClass; // } // // public void setMappedClass(Class<?> mappedClass) { // this.mappedClass = mappedClass; // } // // } // Path: src/main/java/in/cubestack/android/lib/storm/mapper/RawQueryMapper.java import in.cubestack.android.lib.storm.core.TableInformation; import android.database.Cursor; /** * */ package in.cubestack.android.lib.storm.mapper; /** * @author supal * */ public class RawQueryMapper implements RowMapper<Object[]> { @Override
public Object[] map(Cursor cursor, TableInformation tableInformation, Object[] instance) {
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/criteria/CompositeRestriction.java
// Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // }
import java.util.LinkedList; import java.util.List; import in.cubestack.android.lib.storm.core.StormRuntimeException;
package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class CompositeRestriction extends PageableRestriction { private static final char OPENING_BRACES = '('; private static final char CLOSING_BRACES = ')'; private static final char SPACE = ' '; private Restriction left; private Restriction right; private RestricitionJoin join; public CompositeRestriction(Restriction left, Restriction right, RestricitionJoin join) { this.left = left; this.right = right; if(! left.getTableInformation().equals(right.getTableInformation())) {
// Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // Path: src/main/java/in/cubestack/android/lib/storm/criteria/CompositeRestriction.java import java.util.LinkedList; import java.util.List; import in.cubestack.android.lib.storm.core.StormRuntimeException; package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class CompositeRestriction extends PageableRestriction { private static final char OPENING_BRACES = '('; private static final char CLOSING_BRACES = ')'; private static final char SPACE = ' '; private Restriction left; private Restriction right; private RestricitionJoin join; public CompositeRestriction(Restriction left, Restriction right, RestricitionJoin join) { this.left = left; this.right = right; if(! left.getTableInformation().equals(right.getTableInformation())) {
throw new StormRuntimeException("The meta data information for resrtictions do not match. " + this+ "\n Details "
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/TestChild.java
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Table;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * Test entity demonstrating the relation with TestEntity. * * @author Supal Dubey * */ @Table(name="CHILD") public class TestChild { public TestChild() { } public TestChild(long id, String name, long parId) { this.id = id; this.name =name; this.parentId = parId; } @PrimaryKey
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestChild.java import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Table; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package in.cubestack.apps.android.storm.entitites; /** * Test entity demonstrating the relation with TestEntity. * * @author Supal Dubey * */ @Table(name="CHILD") public class TestChild { public TestChild() { } public TestChild(long id, String name, long parId) { this.id = id; this.name =name; this.parentId = parId; } @PrimaryKey
@Column(name="ID", type=FieldType.INTEGER )
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/core/DatabaseMetaData.java
// Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/DatabaseUpdatesHandler.java // public interface DatabaseUpdatesHandler { // // public void onCreate(SQLiteDatabase db); // // public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); // // }
import in.cubestack.android.lib.storm.lifecycle.DatabaseUpdatesHandler;
package in.cubestack.android.lib.storm.core; /** * Created by supal on 10/10/14. */ public class DatabaseMetaData { private String name; private int version; private Class<?>[] tables;
// Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/DatabaseUpdatesHandler.java // public interface DatabaseUpdatesHandler { // // public void onCreate(SQLiteDatabase db); // // public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); // // } // Path: src/main/java/in/cubestack/android/lib/storm/core/DatabaseMetaData.java import in.cubestack.android.lib.storm.lifecycle.DatabaseUpdatesHandler; package in.cubestack.android.lib.storm.core; /** * Created by supal on 10/10/14. */ public class DatabaseMetaData { private String name; private int version; private Class<?>[] tables;
private Class<? extends DatabaseUpdatesHandler> handler;
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/task/TaskDispatcher.java
// Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleEnvent.java // public enum LifeCycleEnvent { // // PRE_SAVE("preSave"), // POST_SAVE("postSave"), // PRE_DELETE("preDelete"), // POST_DELETE("postDelete"); // // private String method; // // LifeCycleEnvent(String method) { // this.method = method; // } // // public String method() { // return method; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // }
import java.lang.reflect.Method; import android.os.AsyncTask; import in.cubestack.android.lib.storm.lifecycle.LifeCycleEnvent; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler;
/** * */ package in.cubestack.android.lib.storm.task; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class TaskDispatcher extends AsyncTask<Object, Void, Void> { private LifeCycleHandler<?> lifeCycleHandler;
// Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleEnvent.java // public enum LifeCycleEnvent { // // PRE_SAVE("preSave"), // POST_SAVE("postSave"), // PRE_DELETE("preDelete"), // POST_DELETE("postDelete"); // // private String method; // // LifeCycleEnvent(String method) { // this.method = method; // } // // public String method() { // return method; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // } // Path: src/main/java/in/cubestack/android/lib/storm/task/TaskDispatcher.java import java.lang.reflect.Method; import android.os.AsyncTask; import in.cubestack.android.lib.storm.lifecycle.LifeCycleEnvent; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler; /** * */ package in.cubestack.android.lib.storm.task; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class TaskDispatcher extends AsyncTask<Object, Void, Void> { private LifeCycleHandler<?> lifeCycleHandler;
private LifeCycleEnvent cycleEnvent;
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/TestRandomEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey;
/** * */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="RANDOM") public class TestRandomEntity { @PrimaryKey
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestRandomEntity.java import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey; /** * */ package in.cubestack.apps.android.storm.entitites; /** * @author Supal Dubey * */ @Table(name="RANDOM") public class TestRandomEntity { @PrimaryKey
@Column(name="ID", type = FieldType.LONG, addedVersion = 1)
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/core/ColumnMetaData.java
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.FieldType;
/** * */ package in.cubestack.android.lib.storm.core; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class ColumnMetaData { private String columnName;
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/main/java/in/cubestack/android/lib/storm/core/ColumnMetaData.java import in.cubestack.android.lib.storm.FieldType; /** * */ package in.cubestack.android.lib.storm.core; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class ColumnMetaData { private String columnName;
private FieldType filedTypes;
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/core/RelationMetaData.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // }
import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType;
/** * */ package in.cubestack.android.lib.storm.core; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class RelationMetaData { private Class<?> targetEntity;
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // Path: src/main/java/in/cubestack/android/lib/storm/core/RelationMetaData.java import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; /** * */ package in.cubestack.android.lib.storm.core; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class RelationMetaData { private Class<?> targetEntity;
private CascadeTypes[] cascadeTypes;
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/core/RelationMetaData.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // }
import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType;
/** * */ package in.cubestack.android.lib.storm.core; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class RelationMetaData { private Class<?> targetEntity; private CascadeTypes[] cascadeTypes; private String joinColumn; private String joinOnColumn; private String property; private String alias; private Class<?> backingImplementation; //Default private boolean collectionBacked= true;
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // Path: src/main/java/in/cubestack/android/lib/storm/core/RelationMetaData.java import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; /** * */ package in.cubestack.android.lib.storm.core; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014-15 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ public class RelationMetaData { private Class<?> targetEntity; private CascadeTypes[] cascadeTypes; private String joinColumn; private String joinOnColumn; private String property; private String alias; private Class<?> backingImplementation; //Default private boolean collectionBacked= true;
private FetchType fetchType;
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/core/MetaDataReader.java
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // // Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // } // // Path: src/main/java/in/cubestack/android/lib/storm/util/Reflections.java // public class Reflections { // public static void setField(Object object, String fieldName, Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // try { // Field field = doGetIt(fieldName, object.getClass()); // field.setAccessible(true); // // field.set(object, value); // field.setAccessible(false); // } catch (Exception ex) { // Log.e("ERRORR", "Error while setting " + fieldName + "of " + object.getClass() + " with value " + value, ex); // } // } // // public static Object getFieldStatic(Class<?> object, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, object); // // field.setAccessible(true); // Object returnValue = (Object) field.get(null); // field.setAccessible(false); // // return returnValue; // } // // public static boolean isValidField(Class<?> targetClass, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, targetClass); // if(field == null) { // return false; // } // return true; // } // // public static Object getFieldValue(Object object, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, object.getClass()); // // field.setAccessible(true); // Object returnValue = (Object) field.get(object); // field.setAccessible(false); // return returnValue; // } // // // // private static Field doGetIt(String name, Class<?> clazz) { // Class<?> superClz = clazz; // while (superClz.getSuperclass() != null) { // for (Field field : superClz.getDeclaredFields()) { // if (field.getName().equals(name)) { // return field; // } // } // superClz = superClz.getSuperclass(); // } // return null; // } // }
import java.lang.reflect.Field; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.Database; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler; import in.cubestack.android.lib.storm.util.Reflections;
tableInformation.setAutoGenerated(field.getAnnotation(PrimaryKey.class).autoGenrateKey()); } else { tableInformation.getColumnMetaDataList().add(getColumnMetaData(field)); } } else if (field.isAnnotationPresent(Relation.class)) { RelationMetaData relationMetaData = new RelationMetaDataReader().fetchRelationMetaData(field, field.getAnnotation(Relation.class), aliasGenerator); tableInformation.getRelations().add(relationMetaData); validate(tableInformation,relationMetaData ); } } clazz = clazz.getSuperclass(); } // Validate we have a primary key if (tableInformation.getPrimaryKeyData() == null) { throw new StormException(String.format( "Please update entity %s, to contain atleast one column as Primary Key using @PrimaryKey annotation. Also make sure Primary Key has @Column Annotation", annotation.getName())); } } private void validate(TableInformation tableInfo, RelationMetaData relationMetaData) throws StormException { if(EMPTY_STRING.equals(relationMetaData.getJoinColumn())) { throw new StormRuntimeException(String.format("Join column details missing in @Relation for class %s, mapped for parent class %s ", relationMetaData.getTargetEntity(), tableInfo.getMappedClass())); } try { String joinColumn = relationMetaData.getJoinColumn();
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // // Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // } // // Path: src/main/java/in/cubestack/android/lib/storm/util/Reflections.java // public class Reflections { // public static void setField(Object object, String fieldName, Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // try { // Field field = doGetIt(fieldName, object.getClass()); // field.setAccessible(true); // // field.set(object, value); // field.setAccessible(false); // } catch (Exception ex) { // Log.e("ERRORR", "Error while setting " + fieldName + "of " + object.getClass() + " with value " + value, ex); // } // } // // public static Object getFieldStatic(Class<?> object, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, object); // // field.setAccessible(true); // Object returnValue = (Object) field.get(null); // field.setAccessible(false); // // return returnValue; // } // // public static boolean isValidField(Class<?> targetClass, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, targetClass); // if(field == null) { // return false; // } // return true; // } // // public static Object getFieldValue(Object object, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, object.getClass()); // // field.setAccessible(true); // Object returnValue = (Object) field.get(object); // field.setAccessible(false); // return returnValue; // } // // // // private static Field doGetIt(String name, Class<?> clazz) { // Class<?> superClz = clazz; // while (superClz.getSuperclass() != null) { // for (Field field : superClz.getDeclaredFields()) { // if (field.getName().equals(name)) { // return field; // } // } // superClz = superClz.getSuperclass(); // } // return null; // } // } // Path: src/main/java/in/cubestack/android/lib/storm/core/MetaDataReader.java import java.lang.reflect.Field; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.Database; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler; import in.cubestack.android.lib.storm.util.Reflections; tableInformation.setAutoGenerated(field.getAnnotation(PrimaryKey.class).autoGenrateKey()); } else { tableInformation.getColumnMetaDataList().add(getColumnMetaData(field)); } } else if (field.isAnnotationPresent(Relation.class)) { RelationMetaData relationMetaData = new RelationMetaDataReader().fetchRelationMetaData(field, field.getAnnotation(Relation.class), aliasGenerator); tableInformation.getRelations().add(relationMetaData); validate(tableInformation,relationMetaData ); } } clazz = clazz.getSuperclass(); } // Validate we have a primary key if (tableInformation.getPrimaryKeyData() == null) { throw new StormException(String.format( "Please update entity %s, to contain atleast one column as Primary Key using @PrimaryKey annotation. Also make sure Primary Key has @Column Annotation", annotation.getName())); } } private void validate(TableInformation tableInfo, RelationMetaData relationMetaData) throws StormException { if(EMPTY_STRING.equals(relationMetaData.getJoinColumn())) { throw new StormRuntimeException(String.format("Join column details missing in @Relation for class %s, mapped for parent class %s ", relationMetaData.getTargetEntity(), tableInfo.getMappedClass())); } try { String joinColumn = relationMetaData.getJoinColumn();
if(! Reflections.isValidField(relationMetaData.getTargetEntity(), joinColumn)) {
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/core/MetaDataReader.java
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // // Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // } // // Path: src/main/java/in/cubestack/android/lib/storm/util/Reflections.java // public class Reflections { // public static void setField(Object object, String fieldName, Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // try { // Field field = doGetIt(fieldName, object.getClass()); // field.setAccessible(true); // // field.set(object, value); // field.setAccessible(false); // } catch (Exception ex) { // Log.e("ERRORR", "Error while setting " + fieldName + "of " + object.getClass() + " with value " + value, ex); // } // } // // public static Object getFieldStatic(Class<?> object, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, object); // // field.setAccessible(true); // Object returnValue = (Object) field.get(null); // field.setAccessible(false); // // return returnValue; // } // // public static boolean isValidField(Class<?> targetClass, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, targetClass); // if(field == null) { // return false; // } // return true; // } // // public static Object getFieldValue(Object object, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, object.getClass()); // // field.setAccessible(true); // Object returnValue = (Object) field.get(object); // field.setAccessible(false); // return returnValue; // } // // // // private static Field doGetIt(String name, Class<?> clazz) { // Class<?> superClz = clazz; // while (superClz.getSuperclass() != null) { // for (Field field : superClz.getDeclaredFields()) { // if (field.getName().equals(name)) { // return field; // } // } // superClz = superClz.getSuperclass(); // } // return null; // } // }
import java.lang.reflect.Field; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.Database; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler; import in.cubestack.android.lib.storm.util.Reflections;
} catch (Exception exception) { throw new StormException(String.format("Please check the mapping for @Relation for class %s, mapped for parent class %s", relationMetaData.getTargetEntity(), tableInfo.getMappedClass()), exception); } } private void generateCreate() throws IllegalArgumentException, IllegalAccessException, InstantiationException { tableInformation.setInsertSql(queryGenerator.insertQuery(tableInformation, tableInformation.isAutoGenerated())); } public DatabaseMetaData fetchDatabaseMetaData(Class<?> databaseClass) { Database database = databaseClass.getAnnotation(Database.class); DatabaseMetaData metaData = new DatabaseMetaData(); metaData.setVersion(database.version()); metaData.setName(database.name()); metaData.setTables(database.tables()); metaData.setHandler(database.handler()); return metaData; } private ColumnMetaData getColumnMetaData(Field field) throws IllegalArgumentException, IllegalAccessException { ColumnMetaData columnMetaData = new ColumnMetaData(); Column column = field.getAnnotation(Column.class); String alias = field.getName(); String columnName = column.name(); boolean parentReferenceKey = column.parentReferenceKey(); columnMetaData.setParentReferenceKey(parentReferenceKey); columnMetaData.setAlias(alias); columnMetaData.setColumnName(columnName);
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // // Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // } // // Path: src/main/java/in/cubestack/android/lib/storm/util/Reflections.java // public class Reflections { // public static void setField(Object object, String fieldName, Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // try { // Field field = doGetIt(fieldName, object.getClass()); // field.setAccessible(true); // // field.set(object, value); // field.setAccessible(false); // } catch (Exception ex) { // Log.e("ERRORR", "Error while setting " + fieldName + "of " + object.getClass() + " with value " + value, ex); // } // } // // public static Object getFieldStatic(Class<?> object, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, object); // // field.setAccessible(true); // Object returnValue = (Object) field.get(null); // field.setAccessible(false); // // return returnValue; // } // // public static boolean isValidField(Class<?> targetClass, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, targetClass); // if(field == null) { // return false; // } // return true; // } // // public static Object getFieldValue(Object object, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // Field field = doGetIt(fieldName, object.getClass()); // // field.setAccessible(true); // Object returnValue = (Object) field.get(object); // field.setAccessible(false); // return returnValue; // } // // // // private static Field doGetIt(String name, Class<?> clazz) { // Class<?> superClz = clazz; // while (superClz.getSuperclass() != null) { // for (Field field : superClz.getDeclaredFields()) { // if (field.getName().equals(name)) { // return field; // } // } // superClz = superClz.getSuperclass(); // } // return null; // } // } // Path: src/main/java/in/cubestack/android/lib/storm/core/MetaDataReader.java import java.lang.reflect.Field; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.Database; import in.cubestack.android.lib.storm.annotation.LifeCycle; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Relation; import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler; import in.cubestack.android.lib.storm.util.Reflections; } catch (Exception exception) { throw new StormException(String.format("Please check the mapping for @Relation for class %s, mapped for parent class %s", relationMetaData.getTargetEntity(), tableInfo.getMappedClass()), exception); } } private void generateCreate() throws IllegalArgumentException, IllegalAccessException, InstantiationException { tableInformation.setInsertSql(queryGenerator.insertQuery(tableInformation, tableInformation.isAutoGenerated())); } public DatabaseMetaData fetchDatabaseMetaData(Class<?> databaseClass) { Database database = databaseClass.getAnnotation(Database.class); DatabaseMetaData metaData = new DatabaseMetaData(); metaData.setVersion(database.version()); metaData.setName(database.name()); metaData.setTables(database.tables()); metaData.setHandler(database.handler()); return metaData; } private ColumnMetaData getColumnMetaData(Field field) throws IllegalArgumentException, IllegalAccessException { ColumnMetaData columnMetaData = new ColumnMetaData(); Column column = field.getAnnotation(Column.class); String alias = field.getName(); String columnName = column.name(); boolean parentReferenceKey = column.parentReferenceKey(); columnMetaData.setParentReferenceKey(parentReferenceKey); columnMetaData.setAlias(alias); columnMetaData.setColumnName(columnName);
FieldType fieldType = column.type();
supaldubey/storm
src/test/java/in/cubestack/android/lib/storm/criteria/MultiCriteriaTests.java
// Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java // @Table(name="TEST_TAB") // @LifeCycle(handler=TestHandler.class) // public class TestEntity { // // @PrimaryKey // @Column(name="ID", type=FieldType.INTEGER) // private int id; // // @Column(name="NAME", type=FieldType.TEXT) // private String name; // // @Column(name="RATE", type=FieldType.DOUBLE) // private double rate; // // // @Column(name="PRICE", type=FieldType.REAL) // private int price; // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestChild.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private List<TestChild> childs =new ArrayList<TestChild>(); // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestSetBasedEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private Set<TestSetBasedEntity> chils; // // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id",joinColumn="parentId", targetEntity = TestRandomEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private TestRandomEntity entity; // // @Relation(fetchType=FetchType.EAGER, joinColumn="parentId", targetEntity = TestAnother.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private TestAnother another; // // public int getId() { // return id; // } // // // public void setId(int id) { // this.id = id; // } // // // public String getName() { // return name; // } // // // public void setName(String name) { // this.name = name; // } // // // public double getRate() { // return rate; // } // // // public void setRate(double rate) { // this.rate = rate; // } // // // public int getPrice() { // return price; // } // // // public void setPrice(int price) { // this.price = price; // } // // // public List<TestChild> getChilds() { // return childs; // } // // // public void setChilds(List<TestChild> childs) { // this.childs = childs; // } // // // public Set<TestSetBasedEntity> getChils() { // return chils; // } // // // public void setChils(Set<TestSetBasedEntity> chils) { // this.chils = chils; // } // // // public TestRandomEntity getEntity() { // return entity; // } // // // public void setEntity(TestRandomEntity entity) { // this.entity = entity; // } // // // public TestAnother getAnother() { // return another; // } // // // public void setAnother(TestAnother another) { // this.another = another; // } // // // // // // // // // }
import org.junit.Assert; import org.junit.Before; import org.junit.Test; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.apps.android.storm.entitites.TestEntity;
/** * */ package in.cubestack.android.lib.storm.criteria; /** * @author Supal Dubey * */ public class MultiCriteriaTests { private Restrictions restrictions; @Before public void init() {
// Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java // @Table(name="TEST_TAB") // @LifeCycle(handler=TestHandler.class) // public class TestEntity { // // @PrimaryKey // @Column(name="ID", type=FieldType.INTEGER) // private int id; // // @Column(name="NAME", type=FieldType.TEXT) // private String name; // // @Column(name="RATE", type=FieldType.DOUBLE) // private double rate; // // // @Column(name="PRICE", type=FieldType.REAL) // private int price; // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestChild.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private List<TestChild> childs =new ArrayList<TestChild>(); // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestSetBasedEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private Set<TestSetBasedEntity> chils; // // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id",joinColumn="parentId", targetEntity = TestRandomEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private TestRandomEntity entity; // // @Relation(fetchType=FetchType.EAGER, joinColumn="parentId", targetEntity = TestAnother.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private TestAnother another; // // public int getId() { // return id; // } // // // public void setId(int id) { // this.id = id; // } // // // public String getName() { // return name; // } // // // public void setName(String name) { // this.name = name; // } // // // public double getRate() { // return rate; // } // // // public void setRate(double rate) { // this.rate = rate; // } // // // public int getPrice() { // return price; // } // // // public void setPrice(int price) { // this.price = price; // } // // // public List<TestChild> getChilds() { // return childs; // } // // // public void setChilds(List<TestChild> childs) { // this.childs = childs; // } // // // public Set<TestSetBasedEntity> getChils() { // return chils; // } // // // public void setChils(Set<TestSetBasedEntity> chils) { // this.chils = chils; // } // // // public TestRandomEntity getEntity() { // return entity; // } // // // public void setEntity(TestRandomEntity entity) { // this.entity = entity; // } // // // public TestAnother getAnother() { // return another; // } // // // public void setAnother(TestAnother another) { // this.another = another; // } // // // // // // // // // } // Path: src/test/java/in/cubestack/android/lib/storm/criteria/MultiCriteriaTests.java import org.junit.Assert; import org.junit.Before; import org.junit.Test; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.apps.android.storm.entitites.TestEntity; /** * */ package in.cubestack.android.lib.storm.criteria; /** * @author Supal Dubey * */ public class MultiCriteriaTests { private Restrictions restrictions; @Before public void init() {
restrictions = StormRestrictions.restrictionsFor(TestEntity.class);
supaldubey/storm
src/test/java/in/cubestack/android/lib/storm/criteria/MultiCriteriaTests.java
// Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java // @Table(name="TEST_TAB") // @LifeCycle(handler=TestHandler.class) // public class TestEntity { // // @PrimaryKey // @Column(name="ID", type=FieldType.INTEGER) // private int id; // // @Column(name="NAME", type=FieldType.TEXT) // private String name; // // @Column(name="RATE", type=FieldType.DOUBLE) // private double rate; // // // @Column(name="PRICE", type=FieldType.REAL) // private int price; // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestChild.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private List<TestChild> childs =new ArrayList<TestChild>(); // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestSetBasedEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private Set<TestSetBasedEntity> chils; // // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id",joinColumn="parentId", targetEntity = TestRandomEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private TestRandomEntity entity; // // @Relation(fetchType=FetchType.EAGER, joinColumn="parentId", targetEntity = TestAnother.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private TestAnother another; // // public int getId() { // return id; // } // // // public void setId(int id) { // this.id = id; // } // // // public String getName() { // return name; // } // // // public void setName(String name) { // this.name = name; // } // // // public double getRate() { // return rate; // } // // // public void setRate(double rate) { // this.rate = rate; // } // // // public int getPrice() { // return price; // } // // // public void setPrice(int price) { // this.price = price; // } // // // public List<TestChild> getChilds() { // return childs; // } // // // public void setChilds(List<TestChild> childs) { // this.childs = childs; // } // // // public Set<TestSetBasedEntity> getChils() { // return chils; // } // // // public void setChils(Set<TestSetBasedEntity> chils) { // this.chils = chils; // } // // // public TestRandomEntity getEntity() { // return entity; // } // // // public void setEntity(TestRandomEntity entity) { // this.entity = entity; // } // // // public TestAnother getAnother() { // return another; // } // // // public void setAnother(TestAnother another) { // this.another = another; // } // // // // // // // // // }
import org.junit.Assert; import org.junit.Before; import org.junit.Test; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.apps.android.storm.entitites.TestEntity;
/** * */ package in.cubestack.android.lib.storm.criteria; /** * @author Supal Dubey * */ public class MultiCriteriaTests { private Restrictions restrictions; @Before public void init() { restrictions = StormRestrictions.restrictionsFor(TestEntity.class); } @Test
// Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestEntity.java // @Table(name="TEST_TAB") // @LifeCycle(handler=TestHandler.class) // public class TestEntity { // // @PrimaryKey // @Column(name="ID", type=FieldType.INTEGER) // private int id; // // @Column(name="NAME", type=FieldType.TEXT) // private String name; // // @Column(name="RATE", type=FieldType.DOUBLE) // private double rate; // // // @Column(name="PRICE", type=FieldType.REAL) // private int price; // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestChild.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private List<TestChild> childs =new ArrayList<TestChild>(); // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id", joinColumn="parentId", targetEntity = TestSetBasedEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private Set<TestSetBasedEntity> chils; // // // @Relation(fetchType=FetchType.EAGER, joinOnColumn="id",joinColumn="parentId", targetEntity = TestRandomEntity.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private TestRandomEntity entity; // // @Relation(fetchType=FetchType.EAGER, joinColumn="parentId", targetEntity = TestAnother.class, cascade={CascadeTypes.PERSIST, CascadeTypes.DELETE}) // private TestAnother another; // // public int getId() { // return id; // } // // // public void setId(int id) { // this.id = id; // } // // // public String getName() { // return name; // } // // // public void setName(String name) { // this.name = name; // } // // // public double getRate() { // return rate; // } // // // public void setRate(double rate) { // this.rate = rate; // } // // // public int getPrice() { // return price; // } // // // public void setPrice(int price) { // this.price = price; // } // // // public List<TestChild> getChilds() { // return childs; // } // // // public void setChilds(List<TestChild> childs) { // this.childs = childs; // } // // // public Set<TestSetBasedEntity> getChils() { // return chils; // } // // // public void setChils(Set<TestSetBasedEntity> chils) { // this.chils = chils; // } // // // public TestRandomEntity getEntity() { // return entity; // } // // // public void setEntity(TestRandomEntity entity) { // this.entity = entity; // } // // // public TestAnother getAnother() { // return another; // } // // // public void setAnother(TestAnother another) { // this.another = another; // } // // // // // // // // // } // Path: src/test/java/in/cubestack/android/lib/storm/criteria/MultiCriteriaTests.java import org.junit.Assert; import org.junit.Before; import org.junit.Test; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.apps.android.storm.entitites.TestEntity; /** * */ package in.cubestack.android.lib.storm.criteria; /** * @author Supal Dubey * */ public class MultiCriteriaTests { private Restrictions restrictions; @Before public void init() { restrictions = StormRestrictions.restrictionsFor(TestEntity.class); } @Test
public void testAnd () throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException {
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/annotation/Relation.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.android.lib.storm.annotation; /** * @Relation annotation can be used to provide One to one or One to Many relations to an entity. * <br><br> * <pre> * class Parent { * @PrimaryKey * @Column(name="id", type=LONG) * private int id; * * @Relation(joinColumn="parentId", targetEntity = Child.class}) * private Child child; * } * </pre> * <br><br> * This can be used to declare both as list or single entity. Note that in this case Child entity should have a property with name parentId.<br> * Parent Id would be used by Storm to generate Joins and queries to fetch the data from database. * * @author Supal Dubey * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Relation { /** * The column corresponding to the target entity property. This ideally is the column that defines the Many to One relationships. * This should be a valid property mapped with @COlumn annotation in the target entity. * * For example for Employee - Department relation entities, departmentId in Employee entity should be the Join column. * * * @return the property corresponding to Column on which Join has to be performed. */ String joinColumn(); Class<?> targetEntity();
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // Path: src/main/java/in/cubestack/android/lib/storm/annotation/Relation.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.android.lib.storm.annotation; /** * @Relation annotation can be used to provide One to one or One to Many relations to an entity. * <br><br> * <pre> * class Parent { * @PrimaryKey * @Column(name="id", type=LONG) * private int id; * * @Relation(joinColumn="parentId", targetEntity = Child.class}) * private Child child; * } * </pre> * <br><br> * This can be used to declare both as list or single entity. Note that in this case Child entity should have a property with name parentId.<br> * Parent Id would be used by Storm to generate Joins and queries to fetch the data from database. * * @author Supal Dubey * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Relation { /** * The column corresponding to the target entity property. This ideally is the column that defines the Many to One relationships. * This should be a valid property mapped with @COlumn annotation in the target entity. * * For example for Employee - Department relation entities, departmentId in Employee entity should be the Join column. * * * @return the property corresponding to Column on which Join has to be performed. */ String joinColumn(); Class<?> targetEntity();
CascadeTypes[] cascade() default {CascadeTypes.PERSIST, CascadeTypes.DELETE};
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/annotation/Relation.java
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.android.lib.storm.annotation; /** * @Relation annotation can be used to provide One to one or One to Many relations to an entity. * <br><br> * <pre> * class Parent { * @PrimaryKey * @Column(name="id", type=LONG) * private int id; * * @Relation(joinColumn="parentId", targetEntity = Child.class}) * private Child child; * } * </pre> * <br><br> * This can be used to declare both as list or single entity. Note that in this case Child entity should have a property with name parentId.<br> * Parent Id would be used by Storm to generate Joins and queries to fetch the data from database. * * @author Supal Dubey * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Relation { /** * The column corresponding to the target entity property. This ideally is the column that defines the Many to One relationships. * This should be a valid property mapped with @COlumn annotation in the target entity. * * For example for Employee - Department relation entities, departmentId in Employee entity should be the Join column. * * * @return the property corresponding to Column on which Join has to be performed. */ String joinColumn(); Class<?> targetEntity(); CascadeTypes[] cascade() default {CascadeTypes.PERSIST, CascadeTypes.DELETE}; /** * For future use only. <br>Do not override this to Lazy as of now, as of now we do not have a way to load the information later.. */
// Path: src/main/java/in/cubestack/android/lib/storm/CascadeTypes.java // public enum CascadeTypes { // // DELETE, PERSIST, NONE; // } // // Path: src/main/java/in/cubestack/android/lib/storm/FetchType.java // public enum FetchType { // // EAGER, LAZY; // } // Path: src/main/java/in/cubestack/android/lib/storm/annotation/Relation.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import in.cubestack.android.lib.storm.CascadeTypes; import in.cubestack.android.lib.storm.FetchType; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.android.lib.storm.annotation; /** * @Relation annotation can be used to provide One to one or One to Many relations to an entity. * <br><br> * <pre> * class Parent { * @PrimaryKey * @Column(name="id", type=LONG) * private int id; * * @Relation(joinColumn="parentId", targetEntity = Child.class}) * private Child child; * } * </pre> * <br><br> * This can be used to declare both as list or single entity. Note that in this case Child entity should have a property with name parentId.<br> * Parent Id would be used by Storm to generate Joins and queries to fetch the data from database. * * @author Supal Dubey * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Relation { /** * The column corresponding to the target entity property. This ideally is the column that defines the Many to One relationships. * This should be a valid property mapped with @COlumn annotation in the target entity. * * For example for Employee - Department relation entities, departmentId in Employee entity should be the Join column. * * * @return the property corresponding to Column on which Join has to be performed. */ String joinColumn(); Class<?> targetEntity(); CascadeTypes[] cascade() default {CascadeTypes.PERSIST, CascadeTypes.DELETE}; /** * For future use only. <br>Do not override this to Lazy as of now, as of now we do not have a way to load the information later.. */
FetchType fetchType() default FetchType.EAGER;
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Table;
package in.cubestack.apps.android.storm.entitites; @Table(name = "TEST_TAB") public class RestrictionTestEntity { @PrimaryKey
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey; import in.cubestack.android.lib.storm.annotation.Table; package in.cubestack.apps.android.storm.entitites; @Table(name = "TEST_TAB") public class RestrictionTestEntity { @PrimaryKey
@Column(name = "ID", type = FieldType.INTEGER)
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/core/TableInformation.java
// Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // }
import java.util.List; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler; import java.util.LinkedList;
/** * */ package in.cubestack.android.lib.storm.core; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class TableInformation { private Class<?> mappedClass; private int tableVersion; private String tableName; private ColumnMetaData primaryKeyData; private List<ColumnMetaData> columnMetaDataList = new LinkedList<ColumnMetaData>(); private List<RelationMetaData> relations = new LinkedList<RelationMetaData>(); private String alias;
// Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // } // Path: src/main/java/in/cubestack/android/lib/storm/core/TableInformation.java import java.util.List; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler; import java.util.LinkedList; /** * */ package in.cubestack.android.lib.storm.core; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class TableInformation { private Class<?> mappedClass; private int tableVersion; private String tableName; private ColumnMetaData primaryKeyData; private List<ColumnMetaData> columnMetaDataList = new LinkedList<ColumnMetaData>(); private List<RelationMetaData> relations = new LinkedList<RelationMetaData>(); private String alias;
private LifeCycleHandler<?> handler;
supaldubey/storm
src/main/java/in/cubestack/android/lib/storm/annotation/LifeCycle.java
// Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler;
/** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.android.lib.storm.annotation; /** * * LIfeCycle can be used to consume events triggered during entity lifecycle. <br><br>The Handler declared in below implementation would receive calls from the service * on different lifecycle events. <br><br> * This may be used to control if an entity should be persisted or should be deleted externally. <br> * * For instance, this may act as a Global rule or validation for an entity. <br><br>For example:<br> * * <pre> * public boolean preSave(Entity entity) { * //If time is in past, and entity has past details do not allow to save * if(isTimePast(entity)) { * return false; * } * } *</pre> * * @author Supal Dubey */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface LifeCycle {
// Path: src/main/java/in/cubestack/android/lib/storm/lifecycle/LifeCycleHandler.java // public interface LifeCycleHandler<E> { // // //Will always be Sync as there is a decision to make // public boolean preSave(E entity); // //Can be called Async // public void postSave(E entity, Throwable throwable); // // //Will always be Sync as there is a decision to make // public boolean preDelete(E entity); // //Can be Async // public void postDelete(E entity, Throwable throwable); // } // Path: src/main/java/in/cubestack/android/lib/storm/annotation/LifeCycle.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import in.cubestack.android.lib.storm.lifecycle.LifeCycleHandler; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ package in.cubestack.android.lib.storm.annotation; /** * * LIfeCycle can be used to consume events triggered during entity lifecycle. <br><br>The Handler declared in below implementation would receive calls from the service * on different lifecycle events. <br><br> * This may be used to control if an entity should be persisted or should be deleted externally. <br> * * For instance, this may act as a Global rule or validation for an entity. <br><br>For example:<br> * * <pre> * public boolean preSave(Entity entity) { * //If time is in past, and entity has past details do not allow to save * if(isTimePast(entity)) { * return false; * } * } *</pre> * * @author Supal Dubey */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface LifeCycle {
Class<? extends LifeCycleHandler<?>> handler();
supaldubey/storm
src/test/java/in/cubestack/android/lib/storm/criteria/StormRestrictionTest.java
// Path: src/main/java/in/cubestack/android/lib/storm/SortOrder.java // public enum SortOrder { // ASC, // DESC // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java // @Table(name = "TEST_TAB") // public class RestrictionTestEntity { // // @PrimaryKey // @Column(name = "ID", type = FieldType.INTEGER) // private int id; // // @Column(name = "NAME", type = FieldType.TEXT) // private String name; // // @Column(name = "HOURS", type = FieldType.TEXT) // private int hours; // // @Column(name = "RATE", type = FieldType.REAL) // private float rate; // // @Column(name = "COST", type = FieldType.REAL) // private double cost; // // }
import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import in.cubestack.android.lib.storm.SortOrder; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.android.lib.storm.core.StormRuntimeException; import in.cubestack.apps.android.storm.entitites.RestrictionTestEntity;
/** * */ package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class StormRestrictionTest { private Restrictions restrictions;
// Path: src/main/java/in/cubestack/android/lib/storm/SortOrder.java // public enum SortOrder { // ASC, // DESC // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java // @Table(name = "TEST_TAB") // public class RestrictionTestEntity { // // @PrimaryKey // @Column(name = "ID", type = FieldType.INTEGER) // private int id; // // @Column(name = "NAME", type = FieldType.TEXT) // private String name; // // @Column(name = "HOURS", type = FieldType.TEXT) // private int hours; // // @Column(name = "RATE", type = FieldType.REAL) // private float rate; // // @Column(name = "COST", type = FieldType.REAL) // private double cost; // // } // Path: src/test/java/in/cubestack/android/lib/storm/criteria/StormRestrictionTest.java import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import in.cubestack.android.lib.storm.SortOrder; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.android.lib.storm.core.StormRuntimeException; import in.cubestack.apps.android.storm.entitites.RestrictionTestEntity; /** * */ package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class StormRestrictionTest { private Restrictions restrictions;
@Test(expected = StormRuntimeException.class)
supaldubey/storm
src/test/java/in/cubestack/android/lib/storm/criteria/StormRestrictionTest.java
// Path: src/main/java/in/cubestack/android/lib/storm/SortOrder.java // public enum SortOrder { // ASC, // DESC // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java // @Table(name = "TEST_TAB") // public class RestrictionTestEntity { // // @PrimaryKey // @Column(name = "ID", type = FieldType.INTEGER) // private int id; // // @Column(name = "NAME", type = FieldType.TEXT) // private String name; // // @Column(name = "HOURS", type = FieldType.TEXT) // private int hours; // // @Column(name = "RATE", type = FieldType.REAL) // private float rate; // // @Column(name = "COST", type = FieldType.REAL) // private double cost; // // }
import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import in.cubestack.android.lib.storm.SortOrder; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.android.lib.storm.core.StormRuntimeException; import in.cubestack.apps.android.storm.entitites.RestrictionTestEntity;
/** * */ package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class StormRestrictionTest { private Restrictions restrictions; @Test(expected = StormRuntimeException.class) public void testInvalidClass() { restrictions = StormRestrictions.restrictionsFor(String.class); } public void testInvalidClassExpMsg() { try { restrictions = StormRestrictions.restrictionsFor(String.class); } catch (Exception ex) { Assert.assertTrue(ex instanceof StormRuntimeException); Assert.assertEquals(ex.getMessage(), "Invalid entity, please check your mapppings for " + String.class.getName()); } } @Test(expected=StormRuntimeException.class) public void testBasic_OrderFail () {
// Path: src/main/java/in/cubestack/android/lib/storm/SortOrder.java // public enum SortOrder { // ASC, // DESC // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java // @Table(name = "TEST_TAB") // public class RestrictionTestEntity { // // @PrimaryKey // @Column(name = "ID", type = FieldType.INTEGER) // private int id; // // @Column(name = "NAME", type = FieldType.TEXT) // private String name; // // @Column(name = "HOURS", type = FieldType.TEXT) // private int hours; // // @Column(name = "RATE", type = FieldType.REAL) // private float rate; // // @Column(name = "COST", type = FieldType.REAL) // private double cost; // // } // Path: src/test/java/in/cubestack/android/lib/storm/criteria/StormRestrictionTest.java import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import in.cubestack.android.lib.storm.SortOrder; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.android.lib.storm.core.StormRuntimeException; import in.cubestack.apps.android.storm.entitites.RestrictionTestEntity; /** * */ package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class StormRestrictionTest { private Restrictions restrictions; @Test(expected = StormRuntimeException.class) public void testInvalidClass() { restrictions = StormRestrictions.restrictionsFor(String.class); } public void testInvalidClassExpMsg() { try { restrictions = StormRestrictions.restrictionsFor(String.class); } catch (Exception ex) { Assert.assertTrue(ex instanceof StormRuntimeException); Assert.assertEquals(ex.getMessage(), "Invalid entity, please check your mapppings for " + String.class.getName()); } } @Test(expected=StormRuntimeException.class) public void testBasic_OrderFail () {
restrictions = StormRestrictions.restrictionsFor(RestrictionTestEntity.class);
supaldubey/storm
src/test/java/in/cubestack/android/lib/storm/criteria/StormRestrictionTest.java
// Path: src/main/java/in/cubestack/android/lib/storm/SortOrder.java // public enum SortOrder { // ASC, // DESC // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java // @Table(name = "TEST_TAB") // public class RestrictionTestEntity { // // @PrimaryKey // @Column(name = "ID", type = FieldType.INTEGER) // private int id; // // @Column(name = "NAME", type = FieldType.TEXT) // private String name; // // @Column(name = "HOURS", type = FieldType.TEXT) // private int hours; // // @Column(name = "RATE", type = FieldType.REAL) // private float rate; // // @Column(name = "COST", type = FieldType.REAL) // private double cost; // // }
import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import in.cubestack.android.lib.storm.SortOrder; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.android.lib.storm.core.StormRuntimeException; import in.cubestack.apps.android.storm.entitites.RestrictionTestEntity;
/** * */ package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class StormRestrictionTest { private Restrictions restrictions; @Test(expected = StormRuntimeException.class) public void testInvalidClass() { restrictions = StormRestrictions.restrictionsFor(String.class); } public void testInvalidClassExpMsg() { try { restrictions = StormRestrictions.restrictionsFor(String.class); } catch (Exception ex) { Assert.assertTrue(ex instanceof StormRuntimeException); Assert.assertEquals(ex.getMessage(), "Invalid entity, please check your mapppings for " + String.class.getName()); } } @Test(expected=StormRuntimeException.class) public void testBasic_OrderFail () { restrictions = StormRestrictions.restrictionsFor(RestrictionTestEntity.class); Assert.assertNotNull(restrictions); Restriction res = restrictions.equals("name", "Supal Dubey");
// Path: src/main/java/in/cubestack/android/lib/storm/SortOrder.java // public enum SortOrder { // ASC, // DESC // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java // @Table(name = "TEST_TAB") // public class RestrictionTestEntity { // // @PrimaryKey // @Column(name = "ID", type = FieldType.INTEGER) // private int id; // // @Column(name = "NAME", type = FieldType.TEXT) // private String name; // // @Column(name = "HOURS", type = FieldType.TEXT) // private int hours; // // @Column(name = "RATE", type = FieldType.REAL) // private float rate; // // @Column(name = "COST", type = FieldType.REAL) // private double cost; // // } // Path: src/test/java/in/cubestack/android/lib/storm/criteria/StormRestrictionTest.java import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import in.cubestack.android.lib.storm.SortOrder; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.android.lib.storm.core.StormRuntimeException; import in.cubestack.apps.android.storm.entitites.RestrictionTestEntity; /** * */ package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class StormRestrictionTest { private Restrictions restrictions; @Test(expected = StormRuntimeException.class) public void testInvalidClass() { restrictions = StormRestrictions.restrictionsFor(String.class); } public void testInvalidClassExpMsg() { try { restrictions = StormRestrictions.restrictionsFor(String.class); } catch (Exception ex) { Assert.assertTrue(ex instanceof StormRuntimeException); Assert.assertEquals(ex.getMessage(), "Invalid entity, please check your mapppings for " + String.class.getName()); } } @Test(expected=StormRuntimeException.class) public void testBasic_OrderFail () { restrictions = StormRestrictions.restrictionsFor(RestrictionTestEntity.class); Assert.assertNotNull(restrictions); Restriction res = restrictions.equals("name", "Supal Dubey");
Order order = Order.orderFor(RestrictionTestEntity.class, new String[] {"dsds"}, SortOrder.DESC);
supaldubey/storm
src/test/java/in/cubestack/android/lib/storm/criteria/StormRestrictionTest.java
// Path: src/main/java/in/cubestack/android/lib/storm/SortOrder.java // public enum SortOrder { // ASC, // DESC // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java // @Table(name = "TEST_TAB") // public class RestrictionTestEntity { // // @PrimaryKey // @Column(name = "ID", type = FieldType.INTEGER) // private int id; // // @Column(name = "NAME", type = FieldType.TEXT) // private String name; // // @Column(name = "HOURS", type = FieldType.TEXT) // private int hours; // // @Column(name = "RATE", type = FieldType.REAL) // private float rate; // // @Column(name = "COST", type = FieldType.REAL) // private double cost; // // }
import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import in.cubestack.android.lib.storm.SortOrder; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.android.lib.storm.core.StormRuntimeException; import in.cubestack.apps.android.storm.entitites.RestrictionTestEntity;
/** * */ package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class StormRestrictionTest { private Restrictions restrictions; @Test(expected = StormRuntimeException.class) public void testInvalidClass() { restrictions = StormRestrictions.restrictionsFor(String.class); } public void testInvalidClassExpMsg() { try { restrictions = StormRestrictions.restrictionsFor(String.class); } catch (Exception ex) { Assert.assertTrue(ex instanceof StormRuntimeException); Assert.assertEquals(ex.getMessage(), "Invalid entity, please check your mapppings for " + String.class.getName()); } } @Test(expected=StormRuntimeException.class) public void testBasic_OrderFail () { restrictions = StormRestrictions.restrictionsFor(RestrictionTestEntity.class); Assert.assertNotNull(restrictions); Restriction res = restrictions.equals("name", "Supal Dubey"); Order order = Order.orderFor(RestrictionTestEntity.class, new String[] {"dsds"}, SortOrder.DESC); res.sqlString(order); } @Test
// Path: src/main/java/in/cubestack/android/lib/storm/SortOrder.java // public enum SortOrder { // ASC, // DESC // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/EntityMetaDataCache.java // public class EntityMetaDataCache { // private static final Map<String, TableInformation> cache = new HashMap<String, TableInformation>(); // // private static AliasGenerator aliasGenerator = new AliasGenerator(); // // public static void cacheInformation(Class<?> entityClass, TableInformation metaData) { // cache.put(entityClass.getName(), metaData); // } // // public static TableInformation getMetaData(Class<?> entityClass) throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException { // TableInformation tableInformation = cache.get(entityClass.getName()); // if (tableInformation == null) { // synchronized (EntityMetaDataCache.class) { // if (cache.get(entityClass.getName()) == null) { // tableInformation = new MetaDataReader().readAnnotations(entityClass, aliasGenerator); // cacheInformation(entityClass, tableInformation); // } // } // } // return tableInformation; // } // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormException.java // public class StormException extends Exception { // // private static final long serialVersionUID = -563476450614494464L; // // public StormException(Throwable throwable) { // super(throwable); // } // // public StormException(String msg) { // super(msg); // } // // public StormException(String msg, Exception exception) { // super(msg, exception); // } // // // } // // Path: src/main/java/in/cubestack/android/lib/storm/core/StormRuntimeException.java // public class StormRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -563476450614494464L; // // // public StormRuntimeException(String msg) { // super(msg); // } // // // public StormRuntimeException(String msg, Exception ex) { // super(msg, ex); // } // // // } // // Path: src/test/java/in/cubestack/apps/android/storm/entitites/RestrictionTestEntity.java // @Table(name = "TEST_TAB") // public class RestrictionTestEntity { // // @PrimaryKey // @Column(name = "ID", type = FieldType.INTEGER) // private int id; // // @Column(name = "NAME", type = FieldType.TEXT) // private String name; // // @Column(name = "HOURS", type = FieldType.TEXT) // private int hours; // // @Column(name = "RATE", type = FieldType.REAL) // private float rate; // // @Column(name = "COST", type = FieldType.REAL) // private double cost; // // } // Path: src/test/java/in/cubestack/android/lib/storm/criteria/StormRestrictionTest.java import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import in.cubestack.android.lib.storm.SortOrder; import in.cubestack.android.lib.storm.core.EntityMetaDataCache; import in.cubestack.android.lib.storm.core.StormException; import in.cubestack.android.lib.storm.core.StormRuntimeException; import in.cubestack.apps.android.storm.entitites.RestrictionTestEntity; /** * */ package in.cubestack.android.lib.storm.criteria; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2014 CubeStack. Version built for Flash Back.. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class StormRestrictionTest { private Restrictions restrictions; @Test(expected = StormRuntimeException.class) public void testInvalidClass() { restrictions = StormRestrictions.restrictionsFor(String.class); } public void testInvalidClassExpMsg() { try { restrictions = StormRestrictions.restrictionsFor(String.class); } catch (Exception ex) { Assert.assertTrue(ex instanceof StormRuntimeException); Assert.assertEquals(ex.getMessage(), "Invalid entity, please check your mapppings for " + String.class.getName()); } } @Test(expected=StormRuntimeException.class) public void testBasic_OrderFail () { restrictions = StormRestrictions.restrictionsFor(RestrictionTestEntity.class); Assert.assertNotNull(restrictions); Restriction res = restrictions.equals("name", "Supal Dubey"); Order order = Order.orderFor(RestrictionTestEntity.class, new String[] {"dsds"}, SortOrder.DESC); res.sqlString(order); } @Test
public void testBasic () throws IllegalArgumentException, IllegalAccessException, InstantiationException, StormException {
supaldubey/storm
src/test/java/in/cubestack/apps/android/storm/entitites/TestSetBasedEntity.java
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // }
import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey;
/** * */ package in.cubestack.apps.android.storm.entitites; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * @author Supal Dubey */ @Table(name = "SETTAB") public class TestSetBasedEntity { @PrimaryKey
// Path: src/main/java/in/cubestack/android/lib/storm/FieldType.java // public enum FieldType { // // INTEGER , // TEXT , // REAL, // OBJECT, LONG, DOUBLE ; // // public String getEscapeString() { // return "''"; // } // // public static final String STD_DATE_FORMAT = "yyyy/MM/dd"; // // } // Path: src/test/java/in/cubestack/apps/android/storm/entitites/TestSetBasedEntity.java import in.cubestack.android.lib.storm.annotation.Table; import in.cubestack.android.lib.storm.FieldType; import in.cubestack.android.lib.storm.annotation.Column; import in.cubestack.android.lib.storm.annotation.PrimaryKey; /** * */ package in.cubestack.apps.android.storm.entitites; /** * A core Android SQLite ORM framework build for speed and raw execution. * Copyright (c) 2016 CubeStack. Built for performance, scalability and ease * to use. * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * @author Supal Dubey */ @Table(name = "SETTAB") public class TestSetBasedEntity { @PrimaryKey
@Column(name="ID", type = FieldType.LONG, addedVersion = 1)
ojmakhura/hdbscan
modules/java/sample/JavaSample.java
// Path: modules/java/src/hdbscan/Hdbscan.java // public class Hdbscan{ // static { // System.loadLibrary("hdbscan_java"); // }; // // private int[] labels; // // /** // * Initialise hdbscan* // * // * @param minPoints // */ // private native void initHdbscan(int minPoints); // // /** // * // * @param dataset // * @return // */ // private native int[] runImpl(double[][] dataset); // // /** // * // * @param minPoints // * @return // */ // private native int[] reRunImpl(int minPoints); // // /** // * Call this method to clean up C allocated memory // * // */ // public native void cleanHdbscan(); // // /** // * // * @param minPoints // */ // public Hdbscan(int minPoints){ // initHdbscan(minPoints); // } // // /** // * // * @param dataset // */ // public void run(double[][] dataset){ // labels = runImpl(dataset); // } // // /** // * // * @param minPts // */ // public void reRun(int minPts){ // labels = reRunImpl(minPts); // } // // /** // * // * @return // */ // public int[] getLabels(){ // return this.labels; // } // // /** // * // * @return // */ // public HashMap<Integer, ArrayList<Integer>> getClusterMap(){ // HashMap<Integer, ArrayList<Integer>> table = new HashMap<Integer, ArrayList<Integer>>(); // // if(labels == null || labels.length == 0){ // return null; // } // // for(int i = 0; i < labels.length; i++){ // Integer key = labels[i]; // ArrayList<Integer> list = table.get(key); // // if(list == null){ // list = new ArrayList<Integer>(); // list.add(i); // table.put(key, list); // } else{ // // list.add(i); // } // } // // return table; // } // // }
import java.util.ArrayList; import java.util.HashMap; import hdbscan.Hdbscan;
else if (lineContents.length != numAttributes) System.err.println("Line " + lineIndex + " of data set has incorrect number of attributes."); double[] attributes = new double[numAttributes]; for (int i = 0; i < numAttributes; i++) { try { // If an exception occurs, the attribute will remain 0: attributes[i] = Double.parseDouble(lineContents[i].trim()); } catch (NumberFormatException nfe) { System.err.println("Illegal value on line " + lineIndex + " of data set: " + lineContents[i]); } } dataSet.add(attributes); line = reader.readLine(); } reader.close(); double[][] finalDataSet = new double[dataSet.size()][numAttributes]; for (int i = 0; i < dataSet.size(); i++) { finalDataSet[i] = dataSet.get(i); } return finalDataSet; } public static void main(String[] args) { double mydata[][] = readInDataSet("example_data_set.csv", ",");
// Path: modules/java/src/hdbscan/Hdbscan.java // public class Hdbscan{ // static { // System.loadLibrary("hdbscan_java"); // }; // // private int[] labels; // // /** // * Initialise hdbscan* // * // * @param minPoints // */ // private native void initHdbscan(int minPoints); // // /** // * // * @param dataset // * @return // */ // private native int[] runImpl(double[][] dataset); // // /** // * // * @param minPoints // * @return // */ // private native int[] reRunImpl(int minPoints); // // /** // * Call this method to clean up C allocated memory // * // */ // public native void cleanHdbscan(); // // /** // * // * @param minPoints // */ // public Hdbscan(int minPoints){ // initHdbscan(minPoints); // } // // /** // * // * @param dataset // */ // public void run(double[][] dataset){ // labels = runImpl(dataset); // } // // /** // * // * @param minPts // */ // public void reRun(int minPts){ // labels = reRunImpl(minPts); // } // // /** // * // * @return // */ // public int[] getLabels(){ // return this.labels; // } // // /** // * // * @return // */ // public HashMap<Integer, ArrayList<Integer>> getClusterMap(){ // HashMap<Integer, ArrayList<Integer>> table = new HashMap<Integer, ArrayList<Integer>>(); // // if(labels == null || labels.length == 0){ // return null; // } // // for(int i = 0; i < labels.length; i++){ // Integer key = labels[i]; // ArrayList<Integer> list = table.get(key); // // if(list == null){ // list = new ArrayList<Integer>(); // list.add(i); // table.put(key, list); // } else{ // // list.add(i); // } // } // // return table; // } // // } // Path: modules/java/sample/JavaSample.java import java.util.ArrayList; import java.util.HashMap; import hdbscan.Hdbscan; else if (lineContents.length != numAttributes) System.err.println("Line " + lineIndex + " of data set has incorrect number of attributes."); double[] attributes = new double[numAttributes]; for (int i = 0; i < numAttributes; i++) { try { // If an exception occurs, the attribute will remain 0: attributes[i] = Double.parseDouble(lineContents[i].trim()); } catch (NumberFormatException nfe) { System.err.println("Illegal value on line " + lineIndex + " of data set: " + lineContents[i]); } } dataSet.add(attributes); line = reader.readLine(); } reader.close(); double[][] finalDataSet = new double[dataSet.size()][numAttributes]; for (int i = 0; i < dataSet.size(); i++) { finalDataSet[i] = dataSet.get(i); } return finalDataSet; } public static void main(String[] args) { double mydata[][] = readInDataSet("example_data_set.csv", ",");
Hdbscan sc = new Hdbscan(3);
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/crucible/CrucibleRecipeCategory.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull;
package mezz.jeiaddons.plugins.thaumcraft.crucible; public class CrucibleRecipeCategory extends BlankRecipeCategory { private static final int catalystIndex = 0; private static final int outputIndex = 1; @Nonnull private final IDrawable background; @Nonnull private final IDrawable backgroundDesign; @Nonnull private final IDrawable arrow; @Nonnull private final String localizedName; public CrucibleRecipeCategory(IGuiHelper guiHelper) { ResourceLocation location = new ResourceLocation("minecraft:textures/gui/container/crafting_table.png"); background = guiHelper.createDrawable(location, 85, 30, 60, 26, 10, 20, 60, 0); ResourceLocation backgroundDesignLocation = new ResourceLocation("thaumcraft", "textures/gui/gui_researchbook_overlay.png"); backgroundDesign = guiHelper.createDrawable(backgroundDesignLocation, 0, 20, 60, 50); arrow = guiHelper.createDrawable(backgroundDesignLocation, 100, 82, 16, 16); localizedName = StatCollector.translateToLocal("recipe.type.crucible"); } @Nonnull @Override public String getUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/crucible/CrucibleRecipeCategory.java import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; package mezz.jeiaddons.plugins.thaumcraft.crucible; public class CrucibleRecipeCategory extends BlankRecipeCategory { private static final int catalystIndex = 0; private static final int outputIndex = 1; @Nonnull private final IDrawable background; @Nonnull private final IDrawable backgroundDesign; @Nonnull private final IDrawable arrow; @Nonnull private final String localizedName; public CrucibleRecipeCategory(IGuiHelper guiHelper) { ResourceLocation location = new ResourceLocation("minecraft:textures/gui/container/crafting_table.png"); background = guiHelper.createDrawable(location, 85, 30, 60, 26, 10, 20, 60, 0); ResourceLocation backgroundDesignLocation = new ResourceLocation("thaumcraft", "textures/gui/gui_researchbook_overlay.png"); backgroundDesign = guiHelper.createDrawable(backgroundDesignLocation, 0, 20, 60, 50); arrow = guiHelper.createDrawable(backgroundDesignLocation, 100, 82, 16, 16); localizedName = StatCollector.translateToLocal("recipe.type.crucible"); } @Nonnull @Override public String getUid() {
return ThaumcraftRecipeUids.CRUCIBLE;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/crucible/CrucibleRecipeHandler.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import javax.annotation.Nonnull;
package mezz.jeiaddons.plugins.thaumcraft.crucible; public class CrucibleRecipeHandler extends ThaumcraftRecipeHandler<CrucibleRecipeWrapper> { @Nonnull @Override public Class<CrucibleRecipeWrapper> getRecipeClass() { return CrucibleRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/crucible/CrucibleRecipeHandler.java import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import javax.annotation.Nonnull; package mezz.jeiaddons.plugins.thaumcraft.crucible; public class CrucibleRecipeHandler extends ThaumcraftRecipeHandler<CrucibleRecipeWrapper> { @Nonnull @Override public Class<CrucibleRecipeWrapper> getRecipeClass() { return CrucibleRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
return ThaumcraftRecipeUids.CRUCIBLE;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneWandRecipeWrapper.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftCraftingRecipeWrapper.java // public abstract class ThaumcraftCraftingRecipeWrapper extends ThaumcraftRecipeWrapper implements ICraftingRecipeWrapper { // protected ThaumcraftCraftingRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers) { // super(jeiHelpers, 66, 18); // } // } // // Path: src/main/java/mezz/jeiaddons/utils/DummyInventoryCrafting.java // public class DummyInventoryCrafting extends InventoryCrafting { // public DummyInventoryCrafting(int width, int height) { // super(new DummyContainer(), width, height); // } // // public static class DummyContainer extends Container { // @Override // public boolean canInteractWith(EntityPlayer playerIn) { // return true; // } // } // }
import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftCraftingRecipeWrapper; import mezz.jeiaddons.utils.DummyInventoryCrafting; import net.minecraft.client.Minecraft; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.AspectList; import thaumcraft.common.lib.crafting.ArcaneWandRecipe; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Arrays; import java.util.Collections; import java.util.List;
package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneWandRecipeWrapper extends ThaumcraftCraftingRecipeWrapper implements IShapedCraftingRecipeWrapper { private static final ArcaneWandRecipe recipe = new ArcaneWandRecipe(); @Nonnull private final List inputs; @Nonnull private final List<ItemStack> outputs; private final InventoryCrafting crafting; private final AspectList aspectList; @Nullable public static ArcaneWandRecipeWrapper create(@Nonnull IJeiHelpers jeiHelpers, @Nonnull ItemStack wandRod, @Nonnull ItemStack wandCap) {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftCraftingRecipeWrapper.java // public abstract class ThaumcraftCraftingRecipeWrapper extends ThaumcraftRecipeWrapper implements ICraftingRecipeWrapper { // protected ThaumcraftCraftingRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers) { // super(jeiHelpers, 66, 18); // } // } // // Path: src/main/java/mezz/jeiaddons/utils/DummyInventoryCrafting.java // public class DummyInventoryCrafting extends InventoryCrafting { // public DummyInventoryCrafting(int width, int height) { // super(new DummyContainer(), width, height); // } // // public static class DummyContainer extends Container { // @Override // public boolean canInteractWith(EntityPlayer playerIn) { // return true; // } // } // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneWandRecipeWrapper.java import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftCraftingRecipeWrapper; import mezz.jeiaddons.utils.DummyInventoryCrafting; import net.minecraft.client.Minecraft; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.AspectList; import thaumcraft.common.lib.crafting.ArcaneWandRecipe; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Arrays; import java.util.Collections; import java.util.List; package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneWandRecipeWrapper extends ThaumcraftCraftingRecipeWrapper implements IShapedCraftingRecipeWrapper { private static final ArcaneWandRecipe recipe = new ArcaneWandRecipe(); @Nonnull private final List inputs; @Nonnull private final List<ItemStack> outputs; private final InventoryCrafting crafting; private final AspectList aspectList; @Nullable public static ArcaneWandRecipeWrapper create(@Nonnull IJeiHelpers jeiHelpers, @Nonnull ItemStack wandRod, @Nonnull ItemStack wandCap) {
InventoryCrafting crafting = new DummyInventoryCrafting(3, 3);
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneWandRecipeHandler.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import javax.annotation.Nonnull; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids;
package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneWandRecipeHandler extends ThaumcraftRecipeHandler<ArcaneWandRecipeWrapper> { @Nonnull @Override public Class<ArcaneWandRecipeWrapper> getRecipeClass() { return ArcaneWandRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneWandRecipeHandler.java import javax.annotation.Nonnull; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneWandRecipeHandler extends ThaumcraftRecipeHandler<ArcaneWandRecipeWrapper> { @Nonnull @Override public Class<ArcaneWandRecipeWrapper> getRecipeClass() { return ArcaneWandRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
return ThaumcraftRecipeUids.ARCANE;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ShapedArcaneRecipeHandler.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import thaumcraft.api.crafting.ShapedArcaneRecipe; import javax.annotation.Nonnull;
package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ShapedArcaneRecipeHandler extends ThaumcraftRecipeHandler<ShapedArcaneRecipe> { @Nonnull private final IJeiHelpers jeiHelpers; public ShapedArcaneRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) { this.jeiHelpers = jeiHelpers; } @Nonnull @Override public Class<ShapedArcaneRecipe> getRecipeClass() { return ShapedArcaneRecipe.class; } @Nonnull @Override public String getRecipeCategoryUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ShapedArcaneRecipeHandler.java import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import thaumcraft.api.crafting.ShapedArcaneRecipe; import javax.annotation.Nonnull; package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ShapedArcaneRecipeHandler extends ThaumcraftRecipeHandler<ShapedArcaneRecipe> { @Nonnull private final IJeiHelpers jeiHelpers; public ShapedArcaneRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) { this.jeiHelpers = jeiHelpers; } @Nonnull @Override public Class<ShapedArcaneRecipe> getRecipeClass() { return ShapedArcaneRecipe.class; } @Nonnull @Override public String getRecipeCategoryUid() {
return ThaumcraftRecipeUids.ARCANE;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneSceptreRecipeHandler.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import javax.annotation.Nonnull; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids;
package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneSceptreRecipeHandler extends ThaumcraftRecipeHandler<ArcaneSceptreRecipeWrapper> { @Nonnull @Override public Class<ArcaneSceptreRecipeWrapper> getRecipeClass() { return ArcaneSceptreRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneSceptreRecipeHandler.java import javax.annotation.Nonnull; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneSceptreRecipeHandler extends ThaumcraftRecipeHandler<ArcaneSceptreRecipeWrapper> { @Nonnull @Override public Class<ArcaneSceptreRecipeWrapper> getRecipeClass() { return ArcaneSceptreRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
return ThaumcraftRecipeUids.ARCANE;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/infusion/InfusionRecipeCategory.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; import java.util.List;
package mezz.jeiaddons.plugins.thaumcraft.infusion; public class InfusionRecipeCategory extends BlankRecipeCategory { private static final int recipeOutputIndex = 0; private static final int recipeInputIndex = 1; private static final int recipeComponentStart = 2; @Nonnull private final IDrawable background; @Nonnull private final IDrawable backgroundDesign; @Nonnull private final String localizedName; public InfusionRecipeCategory(IGuiHelper guiHelper) { ResourceLocation location = new ResourceLocation("minecraft:textures/gui/container/crafting_table.png"); background = guiHelper.createDrawable(location, 85, 16, 60, 54, 16, 56, 90, 0); ResourceLocation backgroundDesignLocation = new ResourceLocation("thaumcraft", "textures/gui/gui_researchbook_overlay.png"); backgroundDesign = guiHelper.createDrawable(backgroundDesignLocation, 200, 75, 50, 50); localizedName = StatCollector.translateToLocal("recipe.type.infusion"); } @Nonnull @Override public String getUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/infusion/InfusionRecipeCategory.java import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; import java.util.List; package mezz.jeiaddons.plugins.thaumcraft.infusion; public class InfusionRecipeCategory extends BlankRecipeCategory { private static final int recipeOutputIndex = 0; private static final int recipeInputIndex = 1; private static final int recipeComponentStart = 2; @Nonnull private final IDrawable background; @Nonnull private final IDrawable backgroundDesign; @Nonnull private final String localizedName; public InfusionRecipeCategory(IGuiHelper guiHelper) { ResourceLocation location = new ResourceLocation("minecraft:textures/gui/container/crafting_table.png"); background = guiHelper.createDrawable(location, 85, 16, 60, 54, 16, 56, 90, 0); ResourceLocation backgroundDesignLocation = new ResourceLocation("thaumcraft", "textures/gui/gui_researchbook_overlay.png"); backgroundDesign = guiHelper.createDrawable(backgroundDesignLocation, 200, 75, 50, 50); localizedName = StatCollector.translateToLocal("recipe.type.infusion"); } @Nonnull @Override public String getUid() {
return ThaumcraftRecipeUids.INFUSION;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/infusion/InfusionRecipeHandler.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import javax.annotation.Nonnull; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids;
package mezz.jeiaddons.plugins.thaumcraft.infusion; public class InfusionRecipeHandler extends ThaumcraftRecipeHandler<InfusionRecipeWrapper> { @Nonnull @Override public Class<InfusionRecipeWrapper> getRecipeClass() { return InfusionRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/infusion/InfusionRecipeHandler.java import javax.annotation.Nonnull; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; package mezz.jeiaddons.plugins.thaumcraft.infusion; public class InfusionRecipeHandler extends ThaumcraftRecipeHandler<InfusionRecipeWrapper> { @Nonnull @Override public Class<InfusionRecipeWrapper> getRecipeClass() { return InfusionRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
return ThaumcraftRecipeUids.INFUSION;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/infernal/InfernalSmeltingRecipeMaker.java
// Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // }
import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.IStackHelper; import mezz.jeiaddons.utils.Log; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.oredict.OreDictionary; import thaumcraft.api.ThaumcraftApi; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map;
package mezz.jeiaddons.plugins.thaumcraft.infernal; public class InfernalSmeltingRecipeMaker { public static List<Object> getRecipes(@Nonnull IJeiHelpers jeiHelpers) { IStackHelper stackHelper = jeiHelpers.getStackHelper(); List<Object> recipes = new ArrayList<>(); Map<Object, ItemStack> smeltingBonus = Collections.emptyMap(); try { smeltingBonus = ReflectionHelper.getPrivateValue(ThaumcraftApi.class, null, "smeltingBonus"); } catch (ReflectionHelper.UnableToFindFieldException e) {
// Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/infernal/InfernalSmeltingRecipeMaker.java import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.IStackHelper; import mezz.jeiaddons.utils.Log; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.oredict.OreDictionary; import thaumcraft.api.ThaumcraftApi; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; package mezz.jeiaddons.plugins.thaumcraft.infernal; public class InfernalSmeltingRecipeMaker { public static List<Object> getRecipes(@Nonnull IJeiHelpers jeiHelpers) { IStackHelper stackHelper = jeiHelpers.getStackHelper(); List<Object> recipes = new ArrayList<>(); Map<Object, ItemStack> smeltingBonus = Collections.emptyMap(); try { smeltingBonus = ReflectionHelper.getPrivateValue(ThaumcraftApi.class, null, "smeltingBonus"); } catch (ReflectionHelper.UnableToFindFieldException e) {
Log.error("Unable to find smeltingBonus in ThaumcraftApi");
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/PluginThaumcraft.java
// Path: src/main/java/mezz/jeiaddons/utils/ModUtil.java // public class ModUtil { // public static boolean isModLoaded(String modname) { // return Loader.isModLoaded(modname); // } // // public static boolean isModLoaded(String modname, String versionRangeString) { // if (!isModLoaded(modname)) { // return false; // } // // if (versionRangeString != null) { // ModContainer mod = Loader.instance().getIndexedModList().get(modname); // ArtifactVersion modVersion = mod.getProcessedVersion(); // // VersionRange versionRange = VersionParser.parseRange(versionRangeString); // DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(modname, versionRange); // // if (!requiredVersion.containsVersion(modVersion)) { // return false; // } // } // // return true; // } // // public static boolean classExists(String className) { // return getClassForName(className) != null; // } // // @Nullable // public static Class getClassForName(String className) { // try { // return Class.forName(className); // } catch (ClassNotFoundException e) { // Log.error("Couldn't find class for {}", className); // return null; // } // } // // @Nullable // public static Class<? extends Container> getContainerClassForName(String className) { // try { // return Class.forName(className).asSubclass(Container.class); // } catch (ClassNotFoundException | ClassCastException e) { // Log.error("Couldn't find class for {}", className); // return null; // } // } // }
import mezz.jei.api.BlankModPlugin; import mezz.jei.api.IModRegistry; import mezz.jei.api.JEIPlugin; import mezz.jeiaddons.utils.ModUtil; import javax.annotation.Nonnull;
package mezz.jeiaddons.plugins.thaumcraft; @JEIPlugin public class PluginThaumcraft extends BlankModPlugin { public static final String modId = "Thaumcraft"; @Override public void register(@Nonnull IModRegistry registry) {
// Path: src/main/java/mezz/jeiaddons/utils/ModUtil.java // public class ModUtil { // public static boolean isModLoaded(String modname) { // return Loader.isModLoaded(modname); // } // // public static boolean isModLoaded(String modname, String versionRangeString) { // if (!isModLoaded(modname)) { // return false; // } // // if (versionRangeString != null) { // ModContainer mod = Loader.instance().getIndexedModList().get(modname); // ArtifactVersion modVersion = mod.getProcessedVersion(); // // VersionRange versionRange = VersionParser.parseRange(versionRangeString); // DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(modname, versionRange); // // if (!requiredVersion.containsVersion(modVersion)) { // return false; // } // } // // return true; // } // // public static boolean classExists(String className) { // return getClassForName(className) != null; // } // // @Nullable // public static Class getClassForName(String className) { // try { // return Class.forName(className); // } catch (ClassNotFoundException e) { // Log.error("Couldn't find class for {}", className); // return null; // } // } // // @Nullable // public static Class<? extends Container> getContainerClassForName(String className) { // try { // return Class.forName(className).asSubclass(Container.class); // } catch (ClassNotFoundException | ClassCastException e) { // Log.error("Couldn't find class for {}", className); // return null; // } // } // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/PluginThaumcraft.java import mezz.jei.api.BlankModPlugin; import mezz.jei.api.IModRegistry; import mezz.jei.api.JEIPlugin; import mezz.jeiaddons.utils.ModUtil; import javax.annotation.Nonnull; package mezz.jeiaddons.plugins.thaumcraft; @JEIPlugin public class PluginThaumcraft extends BlankModPlugin { public static final String modId = "Thaumcraft"; @Override public void register(@Nonnull IModRegistry registry) {
if (ModUtil.isModLoaded(modId)) {
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneSceptreRecipeWrapper.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftCraftingRecipeWrapper.java // public abstract class ThaumcraftCraftingRecipeWrapper extends ThaumcraftRecipeWrapper implements ICraftingRecipeWrapper { // protected ThaumcraftCraftingRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers) { // super(jeiHelpers, 66, 18); // } // } // // Path: src/main/java/mezz/jeiaddons/utils/DummyInventoryCrafting.java // public class DummyInventoryCrafting extends InventoryCrafting { // public DummyInventoryCrafting(int width, int height) { // super(new DummyContainer(), width, height); // } // // public static class DummyContainer extends Container { // @Override // public boolean canInteractWith(EntityPlayer playerIn) { // return true; // } // } // }
import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftCraftingRecipeWrapper; import mezz.jeiaddons.utils.DummyInventoryCrafting; import net.minecraft.client.Minecraft; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.items.ItemsTC; import thaumcraft.common.lib.crafting.ArcaneSceptreRecipe; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Arrays; import java.util.Collections; import java.util.List;
package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneSceptreRecipeWrapper extends ThaumcraftCraftingRecipeWrapper implements IShapedCraftingRecipeWrapper { private static final ArcaneSceptreRecipe recipe = new ArcaneSceptreRecipe(); private static final ItemStack primalCharm = new ItemStack(ItemsTC.primalCharm); @Nonnull private final List inputs; @Nonnull private final List<ItemStack> outputs; private final InventoryCrafting crafting; private final AspectList aspectList; @Nullable public static ArcaneSceptreRecipeWrapper create(@Nonnull IJeiHelpers jeiHelpers, @Nonnull ItemStack wandRod, @Nonnull ItemStack wandCap) {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftCraftingRecipeWrapper.java // public abstract class ThaumcraftCraftingRecipeWrapper extends ThaumcraftRecipeWrapper implements ICraftingRecipeWrapper { // protected ThaumcraftCraftingRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers) { // super(jeiHelpers, 66, 18); // } // } // // Path: src/main/java/mezz/jeiaddons/utils/DummyInventoryCrafting.java // public class DummyInventoryCrafting extends InventoryCrafting { // public DummyInventoryCrafting(int width, int height) { // super(new DummyContainer(), width, height); // } // // public static class DummyContainer extends Container { // @Override // public boolean canInteractWith(EntityPlayer playerIn) { // return true; // } // } // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneSceptreRecipeWrapper.java import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftCraftingRecipeWrapper; import mezz.jeiaddons.utils.DummyInventoryCrafting; import net.minecraft.client.Minecraft; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.items.ItemsTC; import thaumcraft.common.lib.crafting.ArcaneSceptreRecipe; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Arrays; import java.util.Collections; import java.util.List; package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneSceptreRecipeWrapper extends ThaumcraftCraftingRecipeWrapper implements IShapedCraftingRecipeWrapper { private static final ArcaneSceptreRecipe recipe = new ArcaneSceptreRecipe(); private static final ItemStack primalCharm = new ItemStack(ItemsTC.primalCharm); @Nonnull private final List inputs; @Nonnull private final List<ItemStack> outputs; private final InventoryCrafting crafting; private final AspectList aspectList; @Nullable public static ArcaneSceptreRecipeWrapper create(@Nonnull IJeiHelpers jeiHelpers, @Nonnull ItemStack wandRod, @Nonnull ItemStack wandCap) {
InventoryCrafting crafting = new DummyInventoryCrafting(3, 3);
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneRecipeCategory.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // // Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // }
import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import mezz.jeiaddons.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull;
package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneRecipeCategory extends BlankRecipeCategory { private static final int craftOutputSlot = 0; private static final int craftInputSlot1 = 2; @Nonnull private final IDrawable background; @Nonnull private final IDrawable wand; @Nonnull private final String localizedName; @Nonnull private final ICraftingGridHelper craftingGridHelper; public ArcaneRecipeCategory(IGuiHelper guiHelper) { ResourceLocation backgroundLocation = new ResourceLocation("minecraft", "textures/gui/container/crafting_table.png"); background = guiHelper.createDrawable(backgroundLocation, 29, 16, 116, 54, 0, 20, 0, 0); ResourceLocation wandLocation = new ResourceLocation("thaumcraft", "textures/gui/gui_researchbook_overlay.png"); wand = guiHelper.createDrawable(wandLocation, 65, 75, 15, 15); localizedName = StatCollector.translateToLocal("recipe.type.arcane"); craftingGridHelper = guiHelper.createCraftingGridHelper(craftInputSlot1, craftOutputSlot); } @Nonnull @Override public String getUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // // Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneRecipeCategory.java import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import mezz.jeiaddons.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ArcaneRecipeCategory extends BlankRecipeCategory { private static final int craftOutputSlot = 0; private static final int craftInputSlot1 = 2; @Nonnull private final IDrawable background; @Nonnull private final IDrawable wand; @Nonnull private final String localizedName; @Nonnull private final ICraftingGridHelper craftingGridHelper; public ArcaneRecipeCategory(IGuiHelper guiHelper) { ResourceLocation backgroundLocation = new ResourceLocation("minecraft", "textures/gui/container/crafting_table.png"); background = guiHelper.createDrawable(backgroundLocation, 29, 16, 116, 54, 0, 20, 0, 0); ResourceLocation wandLocation = new ResourceLocation("thaumcraft", "textures/gui/gui_researchbook_overlay.png"); wand = guiHelper.createDrawable(wandLocation, 65, 75, 15, 15); localizedName = StatCollector.translateToLocal("recipe.type.arcane"); craftingGridHelper = guiHelper.createCraftingGridHelper(craftInputSlot1, craftOutputSlot); } @Nonnull @Override public String getUid() {
return ThaumcraftRecipeUids.ARCANE;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneRecipeCategory.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // // Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // }
import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import mezz.jeiaddons.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull;
@Override public void drawExtras(@Nonnull Minecraft minecraft) { GlStateManager.enableBlend(); wand.draw(minecraft, 58, 0); GlStateManager.disableBlend(); } @Override public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); guiItemStacks.init(craftOutputSlot, false, 94, 18); for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { int index = craftInputSlot1 + x + (y * 3); guiItemStacks.init(index, true, x * 18, y * 18); } } if (recipeWrapper instanceof IShapedCraftingRecipeWrapper) { IShapedCraftingRecipeWrapper wrapper = (IShapedCraftingRecipeWrapper) recipeWrapper; craftingGridHelper.setInput(guiItemStacks, wrapper.getInputs(), wrapper.getWidth(), wrapper.getHeight()); craftingGridHelper.setOutput(guiItemStacks, wrapper.getOutputs()); } else if (recipeWrapper instanceof ICraftingRecipeWrapper) { ICraftingRecipeWrapper wrapper = (ICraftingRecipeWrapper) recipeWrapper; craftingGridHelper.setInput(guiItemStacks, wrapper.getInputs()); craftingGridHelper.setOutput(guiItemStacks, wrapper.getOutputs()); } else {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // // Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ArcaneRecipeCategory.java import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import mezz.jeiaddons.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; @Override public void drawExtras(@Nonnull Minecraft minecraft) { GlStateManager.enableBlend(); wand.draw(minecraft, 58, 0); GlStateManager.disableBlend(); } @Override public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); guiItemStacks.init(craftOutputSlot, false, 94, 18); for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { int index = craftInputSlot1 + x + (y * 3); guiItemStacks.init(index, true, x * 18, y * 18); } } if (recipeWrapper instanceof IShapedCraftingRecipeWrapper) { IShapedCraftingRecipeWrapper wrapper = (IShapedCraftingRecipeWrapper) recipeWrapper; craftingGridHelper.setInput(guiItemStacks, wrapper.getInputs(), wrapper.getWidth(), wrapper.getHeight()); craftingGridHelper.setOutput(guiItemStacks, wrapper.getOutputs()); } else if (recipeWrapper instanceof ICraftingRecipeWrapper) { ICraftingRecipeWrapper wrapper = (ICraftingRecipeWrapper) recipeWrapper; craftingGridHelper.setInput(guiItemStacks, wrapper.getInputs()); craftingGridHelper.setOutput(guiItemStacks, wrapper.getOutputs()); } else {
Log.error("Can't handle unknown recipe wrapper: {}", recipeWrapper);
mezz/JEIAddons
src/main/java/mezz/jeiaddons/utils/Log.java
// Path: src/main/java/mezz/jeiaddons/JEIAddons.java // @Mod( // modid = JEIAddons.MOD_ID, // version = JEIAddons.VERSION, // clientSideOnly = true, // acceptedMinecraftVersions = "[1.8.9]", // dependencies = // "required-after:JEI@[2.27,);" + // "after:Thaumcraft" // ) // public class JEIAddons { // public static final String MOD_ID = "JEIAddons"; // public static final String VERSION = "@VERSION@"; // // @Mod.EventHandler // public void preInit(@Nonnull FMLPreInitializationEvent event) { // if (event.getSide() != Side.CLIENT) { // return; // } // // initVersionChecker(); // } // // private void initVersionChecker() { // final NBTTagCompound compound = new NBTTagCompound(); // compound.setString("curseProjectName", "jeiaddons"); // compound.setString("curseFilenameParser", "JEIAddons_" + ForgeVersion.mcVersion + "-[].jar"); // FMLInterModComms.sendRuntimeMessage(JEIAddons.MOD_ID, "VersionChecker", "addCurseCheck", compound); // } // }
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import mezz.jeiaddons.JEIAddons;
package mezz.jeiaddons.utils; public class Log { public static void trace(String message, Object... params) { log(Level.TRACE, message, params); } public static void debug(String message, Object... params) { log(Level.DEBUG, message, params); } public static void info(String message, Object... params) { log(Level.INFO, message, params); } public static void warning(String message, Object... params) { log(Level.WARN, message, params); } public static void error(String message, Object... params) { log(Level.ERROR, message, params); } private static void log(Level logLevel, String message, Object... params) {
// Path: src/main/java/mezz/jeiaddons/JEIAddons.java // @Mod( // modid = JEIAddons.MOD_ID, // version = JEIAddons.VERSION, // clientSideOnly = true, // acceptedMinecraftVersions = "[1.8.9]", // dependencies = // "required-after:JEI@[2.27,);" + // "after:Thaumcraft" // ) // public class JEIAddons { // public static final String MOD_ID = "JEIAddons"; // public static final String VERSION = "@VERSION@"; // // @Mod.EventHandler // public void preInit(@Nonnull FMLPreInitializationEvent event) { // if (event.getSide() != Side.CLIENT) { // return; // } // // initVersionChecker(); // } // // private void initVersionChecker() { // final NBTTagCompound compound = new NBTTagCompound(); // compound.setString("curseProjectName", "jeiaddons"); // compound.setString("curseFilenameParser", "JEIAddons_" + ForgeVersion.mcVersion + "-[].jar"); // FMLInterModComms.sendRuntimeMessage(JEIAddons.MOD_ID, "VersionChecker", "addCurseCheck", compound); // } // } // Path: src/main/java/mezz/jeiaddons/utils/Log.java import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import mezz.jeiaddons.JEIAddons; package mezz.jeiaddons.utils; public class Log { public static void trace(String message, Object... params) { log(Level.TRACE, message, params); } public static void debug(String message, Object... params) { log(Level.DEBUG, message, params); } public static void info(String message, Object... params) { log(Level.INFO, message, params); } public static void warning(String message, Object... params) { log(Level.WARN, message, params); } public static void error(String message, Object... params) { log(Level.ERROR, message, params); } private static void log(Level logLevel, String message, Object... params) {
LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params);
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/infernal/InfernalSmeltingRecipeHandler.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import javax.annotation.Nonnull; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids;
package mezz.jeiaddons.plugins.thaumcraft.infernal; public class InfernalSmeltingRecipeHandler extends ThaumcraftRecipeHandler<InfernalSmeltingRecipeWrapper> { @Nonnull @Override public Class<InfernalSmeltingRecipeWrapper> getRecipeClass() { return InfernalSmeltingRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/infernal/InfernalSmeltingRecipeHandler.java import javax.annotation.Nonnull; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; package mezz.jeiaddons.plugins.thaumcraft.infernal; public class InfernalSmeltingRecipeHandler extends ThaumcraftRecipeHandler<InfernalSmeltingRecipeWrapper> { @Nonnull @Override public Class<InfernalSmeltingRecipeWrapper> getRecipeClass() { return InfernalSmeltingRecipeWrapper.class; } @Nonnull @Override public String getRecipeCategoryUid() {
return ThaumcraftRecipeUids.INFERNAL;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/infernal/InfernalSmeltingRecipeCategory.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // // Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // }
import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITooltipCallback; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import mezz.jeiaddons.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; import java.util.List;
public InfernalSmeltingRecipeCategory(IGuiHelper guiHelper) { ResourceLocation location = new ResourceLocation("minecraft", "textures/gui/container/furnace.png"); smeltBackground = guiHelper.createDrawable(location, 55, 16, 82, 54, 0, 0, 0, 30); slotDrawable = guiHelper.getSlotDrawable(); localizedName = StatCollector.translateToLocal("JEIAddons.category.thaumcraft.infernal.smelting"); bonusString = StatCollector.translateToLocal("JEIAddons.thaumcraft.infernal.bonus") + " (0 - 3)"; } @Override @Nonnull public IDrawable getBackground() { return smeltBackground; } @Override public void drawExtras(@Nonnull Minecraft minecraft) { slotDrawable.draw(minecraft, bonusSlotX, bonusSlotY); } @Nonnull @Override public String getTitle() { return localizedName; } @Nonnull @Override public String getUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // // Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/infernal/InfernalSmeltingRecipeCategory.java import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITooltipCallback; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import mezz.jeiaddons.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; import java.util.List; public InfernalSmeltingRecipeCategory(IGuiHelper guiHelper) { ResourceLocation location = new ResourceLocation("minecraft", "textures/gui/container/furnace.png"); smeltBackground = guiHelper.createDrawable(location, 55, 16, 82, 54, 0, 0, 0, 30); slotDrawable = guiHelper.getSlotDrawable(); localizedName = StatCollector.translateToLocal("JEIAddons.category.thaumcraft.infernal.smelting"); bonusString = StatCollector.translateToLocal("JEIAddons.thaumcraft.infernal.bonus") + " (0 - 3)"; } @Override @Nonnull public IDrawable getBackground() { return smeltBackground; } @Override public void drawExtras(@Nonnull Minecraft minecraft) { slotDrawable.draw(minecraft, bonusSlotX, bonusSlotY); } @Nonnull @Override public String getTitle() { return localizedName; } @Nonnull @Override public String getUid() {
return ThaumcraftRecipeUids.INFERNAL;
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/infernal/InfernalSmeltingRecipeCategory.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // // Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // }
import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITooltipCallback; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import mezz.jeiaddons.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; import java.util.List;
@Nonnull @Override public String getUid() { return ThaumcraftRecipeUids.INFERNAL; } @Override public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); guiItemStacks.init(inputSlot, true, 0, 0); guiItemStacks.init(outputSlotSmelt, false, 60, 18); guiItemStacks.init(outputSlotBonus, false, bonusSlotX, bonusSlotY); if (recipeWrapper instanceof InfernalSmeltingRecipeWrapper) { InfernalSmeltingRecipeWrapper recipe = (InfernalSmeltingRecipeWrapper) recipeWrapper; guiItemStacks.setFromRecipe(inputSlot, recipe.getInputs()); guiItemStacks.set(outputSlotSmelt, recipe.getSmeltingOutput()); guiItemStacks.set(outputSlotBonus, recipe.getBonusOutput()); guiItemStacks.addTooltipCallback(new ITooltipCallback<ItemStack>() { @Override public void onTooltip(int slotIndex, boolean input, ItemStack ingredient, List<String> tooltip) { if (slotIndex == outputSlotBonus) { tooltip.add(bonusString); } } }); } else {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // // Path: src/main/java/mezz/jeiaddons/utils/Log.java // public class Log { // // public static void trace(String message, Object... params) { // log(Level.TRACE, message, params); // } // // public static void debug(String message, Object... params) { // log(Level.DEBUG, message, params); // } // // public static void info(String message, Object... params) { // log(Level.INFO, message, params); // } // // public static void warning(String message, Object... params) { // log(Level.WARN, message, params); // } // // public static void error(String message, Object... params) { // log(Level.ERROR, message, params); // } // // private static void log(Level logLevel, String message, Object... params) { // LogManager.getLogger(JEIAddons.MOD_ID).log(logLevel, message, params); // } // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/infernal/InfernalSmeltingRecipeCategory.java import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITooltipCallback; import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import mezz.jeiaddons.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import javax.annotation.Nonnull; import java.util.List; @Nonnull @Override public String getUid() { return ThaumcraftRecipeUids.INFERNAL; } @Override public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); guiItemStacks.init(inputSlot, true, 0, 0); guiItemStacks.init(outputSlotSmelt, false, 60, 18); guiItemStacks.init(outputSlotBonus, false, bonusSlotX, bonusSlotY); if (recipeWrapper instanceof InfernalSmeltingRecipeWrapper) { InfernalSmeltingRecipeWrapper recipe = (InfernalSmeltingRecipeWrapper) recipeWrapper; guiItemStacks.setFromRecipe(inputSlot, recipe.getInputs()); guiItemStacks.set(outputSlotSmelt, recipe.getSmeltingOutput()); guiItemStacks.set(outputSlotBonus, recipe.getBonusOutput()); guiItemStacks.addTooltipCallback(new ITooltipCallback<ItemStack>() { @Override public void onTooltip(int slotIndex, boolean input, ItemStack ingredient, List<String> tooltip) { if (slotIndex == outputSlotBonus) { tooltip.add(bonusString); } } }); } else {
Log.error("Unknown recipe wrapper type: {}", recipeWrapper);
mezz/JEIAddons
src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ShapelessArcaneRecipeHandler.java
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // }
import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import thaumcraft.api.crafting.ShapelessArcaneRecipe; import javax.annotation.Nonnull;
package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ShapelessArcaneRecipeHandler extends ThaumcraftRecipeHandler<ShapelessArcaneRecipe> { @Nonnull private final IJeiHelpers jeiHelpers; public ShapelessArcaneRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) { this.jeiHelpers = jeiHelpers; } @Nonnull @Override public Class<ShapelessArcaneRecipe> getRecipeClass() { return ShapelessArcaneRecipe.class; } @Nonnull @Override public String getRecipeCategoryUid() {
// Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeHandler.java // public abstract class ThaumcraftRecipeHandler<T> implements IRecipeHandler<T> { // @Override // public boolean isRecipeValid(@Nonnull T recipe) { // return true; // } // } // // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/ThaumcraftRecipeUids.java // public class ThaumcraftRecipeUids { // public static final String ARCANE = "thaumcraft.arcane"; // public static final String CRUCIBLE = "thaumcraft.crucible"; // public static final String INFERNAL = "thaumcraft.infernal"; // public static final String INFUSION = "thaumcraft.infusion"; // } // Path: src/main/java/mezz/jeiaddons/plugins/thaumcraft/arcane/ShapelessArcaneRecipeHandler.java import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeHandler; import mezz.jeiaddons.plugins.thaumcraft.ThaumcraftRecipeUids; import thaumcraft.api.crafting.ShapelessArcaneRecipe; import javax.annotation.Nonnull; package mezz.jeiaddons.plugins.thaumcraft.arcane; public class ShapelessArcaneRecipeHandler extends ThaumcraftRecipeHandler<ShapelessArcaneRecipe> { @Nonnull private final IJeiHelpers jeiHelpers; public ShapelessArcaneRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) { this.jeiHelpers = jeiHelpers; } @Nonnull @Override public Class<ShapelessArcaneRecipe> getRecipeClass() { return ShapelessArcaneRecipe.class; } @Nonnull @Override public String getRecipeCategoryUid() {
return ThaumcraftRecipeUids.ARCANE;
yuriytkach/dsync-client
src/main/java/com/yet/dsync/util/DropboxUtil.java
// Path: src/main/java/com/yet/dsync/dto/DropboxChangeType.java // public enum DropboxChangeType { // DELETE, // // FOLDER, // // FILE; // // // public static DropboxChangeType fromMetadata(final Metadata metadata) { // if (metadata instanceof DeletedMetadata) { // return DropboxChangeType.DELETE; // // } else if (metadata instanceof FolderMetadata) { // return DropboxChangeType.FOLDER; // // } else if (metadata instanceof FileMetadata) { // return DropboxChangeType.FILE; // // } else { // throw new DSyncClientException("Unknow Metadata class " + metadata.getClass()); // } // } // // } // // Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // }
import com.dropbox.core.v2.files.FileMetadata; import com.dropbox.core.v2.files.FolderMetadata; import com.dropbox.core.v2.files.Metadata; import com.yet.dsync.dto.DropboxChangeType; import com.yet.dsync.dto.DropboxFileData; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset;
/* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.util; public final class DropboxUtil { private DropboxUtil() { }
// Path: src/main/java/com/yet/dsync/dto/DropboxChangeType.java // public enum DropboxChangeType { // DELETE, // // FOLDER, // // FILE; // // // public static DropboxChangeType fromMetadata(final Metadata metadata) { // if (metadata instanceof DeletedMetadata) { // return DropboxChangeType.DELETE; // // } else if (metadata instanceof FolderMetadata) { // return DropboxChangeType.FOLDER; // // } else if (metadata instanceof FileMetadata) { // return DropboxChangeType.FILE; // // } else { // throw new DSyncClientException("Unknow Metadata class " + metadata.getClass()); // } // } // // } // // Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // } // Path: src/main/java/com/yet/dsync/util/DropboxUtil.java import com.dropbox.core.v2.files.FileMetadata; import com.dropbox.core.v2.files.FolderMetadata; import com.dropbox.core.v2.files.Metadata; import com.yet.dsync.dto.DropboxChangeType; import com.yet.dsync.dto.DropboxFileData; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; /* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.util; public final class DropboxUtil { private DropboxUtil() { }
public static DropboxFileData convertMetadata(final Metadata metadata) {
yuriytkach/dsync-client
src/main/java/com/yet/dsync/util/DropboxUtil.java
// Path: src/main/java/com/yet/dsync/dto/DropboxChangeType.java // public enum DropboxChangeType { // DELETE, // // FOLDER, // // FILE; // // // public static DropboxChangeType fromMetadata(final Metadata metadata) { // if (metadata instanceof DeletedMetadata) { // return DropboxChangeType.DELETE; // // } else if (metadata instanceof FolderMetadata) { // return DropboxChangeType.FOLDER; // // } else if (metadata instanceof FileMetadata) { // return DropboxChangeType.FILE; // // } else { // throw new DSyncClientException("Unknow Metadata class " + metadata.getClass()); // } // } // // } // // Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // }
import com.dropbox.core.v2.files.FileMetadata; import com.dropbox.core.v2.files.FolderMetadata; import com.dropbox.core.v2.files.Metadata; import com.yet.dsync.dto.DropboxChangeType; import com.yet.dsync.dto.DropboxFileData; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset;
/* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.util; public final class DropboxUtil { private DropboxUtil() { } public static DropboxFileData convertMetadata(final Metadata metadata) { final DropboxFileData.DropboxFileDataBuilder builder = DropboxFileData.builder()
// Path: src/main/java/com/yet/dsync/dto/DropboxChangeType.java // public enum DropboxChangeType { // DELETE, // // FOLDER, // // FILE; // // // public static DropboxChangeType fromMetadata(final Metadata metadata) { // if (metadata instanceof DeletedMetadata) { // return DropboxChangeType.DELETE; // // } else if (metadata instanceof FolderMetadata) { // return DropboxChangeType.FOLDER; // // } else if (metadata instanceof FileMetadata) { // return DropboxChangeType.FILE; // // } else { // throw new DSyncClientException("Unknow Metadata class " + metadata.getClass()); // } // } // // } // // Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // } // Path: src/main/java/com/yet/dsync/util/DropboxUtil.java import com.dropbox.core.v2.files.FileMetadata; import com.dropbox.core.v2.files.FolderMetadata; import com.dropbox.core.v2.files.Metadata; import com.yet.dsync.dto.DropboxChangeType; import com.yet.dsync.dto.DropboxFileData; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; /* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.util; public final class DropboxUtil { private DropboxUtil() { } public static DropboxFileData convertMetadata(final Metadata metadata) { final DropboxFileData.DropboxFileDataBuilder builder = DropboxFileData.builder()
.changeType(DropboxChangeType.fromMetadata(metadata))
yuriytkach/dsync-client
src/main/java/com/yet/dsync/dao/ConfigDao.java
// Path: src/main/java/com/yet/dsync/util/Config.java // public enum Config { // // ACCESS_TOKEN, // // CURSOR, // // LOCAL_DIR, // // INITIAL_SYNC; // // public static final String DB_NAME = "dsync.db"; // // public static String getProgramConfigurationDirectory() { // return System.getProperty("user.home") + File.separator + ".dsyncclient"; // } // // }
import com.yet.dsync.util.Config; import lombok.SneakyThrows; import org.apache.commons.lang3.StringUtils; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock;
/* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.dao; public class ConfigDao { public static final String YES = "yes"; public static final String NO = "no"; static final String CREATE_TABLE_STATEMENT = "CREATE TABLE CONFIG (" + "KEY TEXT PRIMARY KEY NOT NULL," + "VALUE TEXT NOT NULL" + ")"; private static final String SELECT_STATEMENT = "SELECT VALUE FROM CONFIG WHERE KEY = ?"; private static final String INSERT_STATEMENT = "INSERT INTO CONFIG (KEY,VALUE) VALUES (?,?)"; private static final String UPDATE_STATEMENT = "UPDATE CONFIG SET VALUE = ? WHERE KEY = ?"; private final PreparedStatement readStatement; private final PreparedStatement insertStatement; private final PreparedStatement updateStatement; private final Lock syncLock = new ReentrantLock(true); @SneakyThrows public ConfigDao(final Connection connection) { readStatement = connection.prepareStatement(SELECT_STATEMENT); insertStatement = connection.prepareStatement(INSERT_STATEMENT); updateStatement = connection.prepareStatement(UPDATE_STATEMENT); } @SneakyThrows
// Path: src/main/java/com/yet/dsync/util/Config.java // public enum Config { // // ACCESS_TOKEN, // // CURSOR, // // LOCAL_DIR, // // INITIAL_SYNC; // // public static final String DB_NAME = "dsync.db"; // // public static String getProgramConfigurationDirectory() { // return System.getProperty("user.home") + File.separator + ".dsyncclient"; // } // // } // Path: src/main/java/com/yet/dsync/dao/ConfigDao.java import com.yet.dsync.util.Config; import lombok.SneakyThrows; import org.apache.commons.lang3.StringUtils; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.dao; public class ConfigDao { public static final String YES = "yes"; public static final String NO = "no"; static final String CREATE_TABLE_STATEMENT = "CREATE TABLE CONFIG (" + "KEY TEXT PRIMARY KEY NOT NULL," + "VALUE TEXT NOT NULL" + ")"; private static final String SELECT_STATEMENT = "SELECT VALUE FROM CONFIG WHERE KEY = ?"; private static final String INSERT_STATEMENT = "INSERT INTO CONFIG (KEY,VALUE) VALUES (?,?)"; private static final String UPDATE_STATEMENT = "UPDATE CONFIG SET VALUE = ? WHERE KEY = ?"; private final PreparedStatement readStatement; private final PreparedStatement insertStatement; private final PreparedStatement updateStatement; private final Lock syncLock = new ReentrantLock(true); @SneakyThrows public ConfigDao(final Connection connection) { readStatement = connection.prepareStatement(SELECT_STATEMENT); insertStatement = connection.prepareStatement(INSERT_STATEMENT); updateStatement = connection.prepareStatement(UPDATE_STATEMENT); } @SneakyThrows
public String read(final Config key) {
yuriytkach/dsync-client
src/main/java/com/yet/dsync/dao/MetadataDao.java
// Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // } // // Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import com.yet.dsync.dto.DropboxFileData; import com.yet.dsync.exception.DSyncClientException; import lombok.SneakyThrows; import java.math.BigDecimal; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Collection; import java.util.LinkedList; import java.util.Set;
private static final int UPD_PARAM_PATH = 1; private static final int UPD_PARAM_PATH_LOWER = UPD_PARAM_PATH + 1; private static final int UPD_PARAM_REV = UPD_PARAM_PATH_LOWER + 1; private static final int UPD_PARAM_SIZE = UPD_PARAM_REV + 1; private static final int UPD_PARAM_SRVDATE = UPD_PARAM_SIZE + 1; private static final int UPD_PARAM_CLIDATE = UPD_PARAM_SRVDATE + 1; private static final int UPD_PARAM_ID = UPD_PARAM_CLIDATE + 1; private final PreparedStatement readByIdStatement; private final PreparedStatement readNotLoadedStatement; private final PreparedStatement readByPLowerStatement; private final PreparedStatement insertStatement; private final PreparedStatement updateLoadedStatement; private final PreparedStatement updateFieldsStatement; private final PreparedStatement deleteByPathStatement; private final Lock syncLock = new ReentrantLock(true); @SneakyThrows public MetadataDao(final Connection connection) { readByIdStatement = connection.prepareStatement(SELECT_BY_ID_STATEMENT); readNotLoadedStatement = connection.prepareStatement(SELECT_NOT_LOADED_STATEMENT); readByPLowerStatement = connection.prepareStatement(SELECT_BY_PLOWER_STATEMENT); insertStatement = connection.prepareStatement(INSERT_STATEMENT); updateLoadedStatement = connection.prepareStatement(UPDATE_LOADED_STATEMENT); updateFieldsStatement = connection.prepareStatement(UPDATE_FIELDS_STATEMENT); deleteByPathStatement = connection.prepareStatement(DELETE_BY_PATH_STATEMENT); } @SneakyThrows
// Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // } // // Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: src/main/java/com/yet/dsync/dao/MetadataDao.java import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import com.yet.dsync.dto.DropboxFileData; import com.yet.dsync.exception.DSyncClientException; import lombok.SneakyThrows; import java.math.BigDecimal; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Collection; import java.util.LinkedList; import java.util.Set; private static final int UPD_PARAM_PATH = 1; private static final int UPD_PARAM_PATH_LOWER = UPD_PARAM_PATH + 1; private static final int UPD_PARAM_REV = UPD_PARAM_PATH_LOWER + 1; private static final int UPD_PARAM_SIZE = UPD_PARAM_REV + 1; private static final int UPD_PARAM_SRVDATE = UPD_PARAM_SIZE + 1; private static final int UPD_PARAM_CLIDATE = UPD_PARAM_SRVDATE + 1; private static final int UPD_PARAM_ID = UPD_PARAM_CLIDATE + 1; private final PreparedStatement readByIdStatement; private final PreparedStatement readNotLoadedStatement; private final PreparedStatement readByPLowerStatement; private final PreparedStatement insertStatement; private final PreparedStatement updateLoadedStatement; private final PreparedStatement updateFieldsStatement; private final PreparedStatement deleteByPathStatement; private final Lock syncLock = new ReentrantLock(true); @SneakyThrows public MetadataDao(final Connection connection) { readByIdStatement = connection.prepareStatement(SELECT_BY_ID_STATEMENT); readNotLoadedStatement = connection.prepareStatement(SELECT_NOT_LOADED_STATEMENT); readByPLowerStatement = connection.prepareStatement(SELECT_BY_PLOWER_STATEMENT); insertStatement = connection.prepareStatement(INSERT_STATEMENT); updateLoadedStatement = connection.prepareStatement(UPDATE_LOADED_STATEMENT); updateFieldsStatement = connection.prepareStatement(UPDATE_FIELDS_STATEMENT); deleteByPathStatement = connection.prepareStatement(DELETE_BY_PATH_STATEMENT); } @SneakyThrows
public DropboxFileData readByLowerPath(final String lowerPath) {
yuriytkach/dsync-client
src/main/java/com/yet/dsync/dao/MetadataDao.java
// Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // } // // Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import com.yet.dsync.dto.DropboxFileData; import com.yet.dsync.exception.DSyncClientException; import lombok.SneakyThrows; import java.math.BigDecimal; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Collection; import java.util.LinkedList; import java.util.Set;
} } finally { syncLock.unlock(); } } @SneakyThrows private void fillInsertStatement(final DropboxFileData fileData) { insertStatement.setString(COL_ID, fileData.getId()); insertStatement.setString(COL_PATH, fileData.getPathDisplay()); insertStatement.setString(COL_PATH_LOWER, fileData.getPathLower()); insertStatement.setBoolean(COL_LOADED, false); setStatementParams(insertStatement, COL_REV, fileData.getRev(), Types.VARCHAR); setStatementParams(insertStatement, COL_SIZE, fileData.getSize(), Types.BIGINT); setStatementParams(insertStatement, COL_SRVDATE, dateTimeToLong(fileData.getServerModified()), Types.BIGINT); setStatementParams(insertStatement, COL_CLIDATE, dateTimeToLong(fileData.getClientModified()), Types.BIGINT); } @SneakyThrows public void write(final Set<DropboxFileData> fileDataSet) { syncLock.lock(); try { fileDataSet.forEach(fileData -> { try { fillInsertStatement(fileData); insertStatement.addBatch(); } catch (final SQLException ex) {
// Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // } // // Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: src/main/java/com/yet/dsync/dao/MetadataDao.java import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import com.yet.dsync.dto.DropboxFileData; import com.yet.dsync.exception.DSyncClientException; import lombok.SneakyThrows; import java.math.BigDecimal; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Collection; import java.util.LinkedList; import java.util.Set; } } finally { syncLock.unlock(); } } @SneakyThrows private void fillInsertStatement(final DropboxFileData fileData) { insertStatement.setString(COL_ID, fileData.getId()); insertStatement.setString(COL_PATH, fileData.getPathDisplay()); insertStatement.setString(COL_PATH_LOWER, fileData.getPathLower()); insertStatement.setBoolean(COL_LOADED, false); setStatementParams(insertStatement, COL_REV, fileData.getRev(), Types.VARCHAR); setStatementParams(insertStatement, COL_SIZE, fileData.getSize(), Types.BIGINT); setStatementParams(insertStatement, COL_SRVDATE, dateTimeToLong(fileData.getServerModified()), Types.BIGINT); setStatementParams(insertStatement, COL_CLIDATE, dateTimeToLong(fileData.getClientModified()), Types.BIGINT); } @SneakyThrows public void write(final Set<DropboxFileData> fileDataSet) { syncLock.lock(); try { fileDataSet.forEach(fileData -> { try { fillInsertStatement(fileData); insertStatement.addBatch(); } catch (final SQLException ex) {
throw new DSyncClientException(ex);
yuriytkach/dsync-client
src/main/java/com/yet/dsync/dto/LocalFolderChangeType.java
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import com.yet.dsync.exception.DSyncClientException; import java.nio.file.Path; import java.nio.file.StandardWatchEventKinds; import java.nio.file.WatchEvent.Kind;
/* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.dto; public enum LocalFolderChangeType { CREATE, MODIFY, DELETE; public static LocalFolderChangeType fromWatchEventKind(final Kind<Path> watchEventKind) { if (watchEventKind == StandardWatchEventKinds.ENTRY_CREATE) { return CREATE; } else if (watchEventKind == StandardWatchEventKinds.ENTRY_MODIFY) { return MODIFY; } else if (watchEventKind == StandardWatchEventKinds.ENTRY_DELETE) { return DELETE; } else {
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: src/main/java/com/yet/dsync/dto/LocalFolderChangeType.java import com.yet.dsync.exception.DSyncClientException; import java.nio.file.Path; import java.nio.file.StandardWatchEventKinds; import java.nio.file.WatchEvent.Kind; /* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.dto; public enum LocalFolderChangeType { CREATE, MODIFY, DELETE; public static LocalFolderChangeType fromWatchEventKind(final Kind<Path> watchEventKind) { if (watchEventKind == StandardWatchEventKinds.ENTRY_CREATE) { return CREATE; } else if (watchEventKind == StandardWatchEventKinds.ENTRY_MODIFY) { return MODIFY; } else if (watchEventKind == StandardWatchEventKinds.ENTRY_DELETE) { return DELETE; } else {
throw new DSyncClientException("Unsupported watchEventKind " + watchEventKind);
yuriytkach/dsync-client
src/main/java/com/yet/dsync/service/DropboxChange.java
// Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // }
import com.yet.dsync.dto.DropboxFileData; import java.util.Set;
/* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.service; @FunctionalInterface public interface DropboxChange {
// Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java // @Data // @Builder(toBuilder = true) // public final class DropboxFileData { // // private final DropboxChangeType changeType; // // private final String pathDisplay; // // private final String pathLower; // // private final String id; // // private final String rev; // // private final Long size; // // private final LocalDateTime serverModified; // // private final LocalDateTime clientModified; // // public boolean isFile() { // return rev != null; // } // // public boolean isDirectory() { // return id != null && rev == null; // } // // @Override // public String toString() { // String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay; // // if (DropboxChangeType.FOLDER == changeType) { // str += ", id: " + id; // } else if (DropboxChangeType.FILE == changeType) { // str += ", id: " + id + ", rev: " + rev + ", size: " + size // + ", client: " + clientModified + ", server: " + serverModified; // } // // str += "]"; // return str; // } // } // Path: src/main/java/com/yet/dsync/service/DropboxChange.java import com.yet.dsync.dto.DropboxFileData; import java.util.Set; /* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.service; @FunctionalInterface public interface DropboxChange {
void processChange(Set<DropboxFileData> data);
yuriytkach/dsync-client
src/main/java/com/yet/dsync/service/AbstractChangeProcessingService.java
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.yet.dsync.exception.DSyncClientException; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import lombok.RequiredArgsConstructor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.Comparator; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.ThreadFactory;
return globalOperationsTracker; } /** * If the changeData is file, then scheduling it either in quick or slow * processing queue based on size. * * Otherwise, scheduling it to quick processing queue. * * @param changeData * Change data object that needs to be scheduled for processing */ public void scheduleProcessing(final T changeData) { final String pathLower = extractPathLower(changeData); if (globalOperationsTracker.isTracked(pathLower)) { LOG.debug("Path is already tracked. Skip: {}", () -> pathLower); } else { try { if (isFile(changeData)) { final long size = getFileSize(changeData); if (size > SLOW_THRESHOLD) { slowProcessingQueue.put(changeData); } else { quickProcessingQueue.put(changeData); } } else { quickProcessingQueue.put(changeData); } } catch (final Exception ex) {
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: src/main/java/com/yet/dsync/service/AbstractChangeProcessingService.java import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.yet.dsync.exception.DSyncClientException; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import lombok.RequiredArgsConstructor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.Comparator; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.ThreadFactory; return globalOperationsTracker; } /** * If the changeData is file, then scheduling it either in quick or slow * processing queue based on size. * * Otherwise, scheduling it to quick processing queue. * * @param changeData * Change data object that needs to be scheduled for processing */ public void scheduleProcessing(final T changeData) { final String pathLower = extractPathLower(changeData); if (globalOperationsTracker.isTracked(pathLower)) { LOG.debug("Path is already tracked. Skip: {}", () -> pathLower); } else { try { if (isFile(changeData)) { final long size = getFileSize(changeData); if (size > SLOW_THRESHOLD) { slowProcessingQueue.put(changeData); } else { quickProcessingQueue.put(changeData); } } else { quickProcessingQueue.put(changeData); } } catch (final Exception ex) {
throw new DSyncClientException(ex);
yuriytkach/dsync-client
src/main/java/com/yet/dsync/util/WatcherRegisterConsumer.java
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import com.yet.dsync.exception.DSyncClientException; import lombok.RequiredArgsConstructor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardWatchEventKinds; import java.nio.file.WatchKey; import java.nio.file.WatchService; import java.nio.file.attribute.BasicFileAttributes; import java.util.function.Consumer;
/* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.util; //import com.sun.nio.file.SensitivityWatchEventModifier; @RequiredArgsConstructor public class WatcherRegisterConsumer implements Consumer<Path> { private static final Logger LOG = LogManager.getLogger(WatcherRegisterConsumer.class); private final WatchService watchService; private final Consumer<WatchKey> watchKeyConsumer; @Override public void accept(final Path path) { if (!path.toFile().exists() || !path.toFile().isDirectory()) {
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: src/main/java/com/yet/dsync/util/WatcherRegisterConsumer.java import com.yet.dsync.exception.DSyncClientException; import lombok.RequiredArgsConstructor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardWatchEventKinds; import java.nio.file.WatchKey; import java.nio.file.WatchService; import java.nio.file.attribute.BasicFileAttributes; import java.util.function.Consumer; /* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.util; //import com.sun.nio.file.SensitivityWatchEventModifier; @RequiredArgsConstructor public class WatcherRegisterConsumer implements Consumer<Path> { private static final Logger LOG = LogManager.getLogger(WatcherRegisterConsumer.class); private final WatchService watchService; private final Consumer<WatchKey> watchKeyConsumer; @Override public void accept(final Path path) { if (!path.toFile().exists() || !path.toFile().isDirectory()) {
throw new DSyncClientException("folder " + path + " does not exist or is not a directory");
yuriytkach/dsync-client
src/main/java/com/yet/dsync/dto/DropboxChangeType.java
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import com.dropbox.core.v2.files.DeletedMetadata; import com.dropbox.core.v2.files.FileMetadata; import com.dropbox.core.v2.files.FolderMetadata; import com.dropbox.core.v2.files.Metadata; import com.yet.dsync.exception.DSyncClientException;
/* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.dto; public enum DropboxChangeType { DELETE, FOLDER, FILE; public static DropboxChangeType fromMetadata(final Metadata metadata) { if (metadata instanceof DeletedMetadata) { return DropboxChangeType.DELETE; } else if (metadata instanceof FolderMetadata) { return DropboxChangeType.FOLDER; } else if (metadata instanceof FileMetadata) { return DropboxChangeType.FILE; } else {
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java // public class DSyncClientException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public DSyncClientException(final String message) { // super(message); // } // // public DSyncClientException(final Throwable cause) { // super(cause); // } // // public DSyncClientException(final String message, final Throwable cause) { // super(message, cause); // } // // public DSyncClientException(final String message, final Throwable cause, // final boolean enableSuppression, final boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: src/main/java/com/yet/dsync/dto/DropboxChangeType.java import com.dropbox.core.v2.files.DeletedMetadata; import com.dropbox.core.v2.files.FileMetadata; import com.dropbox.core.v2.files.FolderMetadata; import com.dropbox.core.v2.files.Metadata; import com.yet.dsync.exception.DSyncClientException; /* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.dto; public enum DropboxChangeType { DELETE, FOLDER, FILE; public static DropboxChangeType fromMetadata(final Metadata metadata) { if (metadata instanceof DeletedMetadata) { return DropboxChangeType.DELETE; } else if (metadata instanceof FolderMetadata) { return DropboxChangeType.FOLDER; } else if (metadata instanceof FileMetadata) { return DropboxChangeType.FILE; } else {
throw new DSyncClientException("Unknow Metadata class " + metadata.getClass());
yuriytkach/dsync-client
src/main/java/com/yet/dsync/service/LocalFolderChange.java
// Path: src/main/java/com/yet/dsync/dto/LocalFolderData.java // @Data // public class LocalFolderData { // // private final Path path; // private final LocalFolderChangeType changeType; // // public boolean isFile() { // return path.toFile().isFile(); // } // // public boolean isDirectory() { // return path.toFile().isDirectory(); // } // // public boolean fileExists() { // return path.toFile().exists(); // } // // public long getSize() { // return path.toFile().length(); // } // // }
import com.yet.dsync.dto.LocalFolderData;
/* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.service; @FunctionalInterface public interface LocalFolderChange {
// Path: src/main/java/com/yet/dsync/dto/LocalFolderData.java // @Data // public class LocalFolderData { // // private final Path path; // private final LocalFolderChangeType changeType; // // public boolean isFile() { // return path.toFile().isFile(); // } // // public boolean isDirectory() { // return path.toFile().isDirectory(); // } // // public boolean fileExists() { // return path.toFile().exists(); // } // // public long getSize() { // return path.toFile().length(); // } // // } // Path: src/main/java/com/yet/dsync/service/LocalFolderChange.java import com.yet.dsync.dto.LocalFolderData; /* * Copyright (c) 2017 Yuriy Tkach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package com.yet.dsync.service; @FunctionalInterface public interface LocalFolderChange {
void processChange(LocalFolderData localFolderData);
otale/tale
src/main/java/com/tale/Application.java
// Path: src/main/java/com/tale/bootstrap/TaleLoader.java // public final class TaleLoader { // // private TaleLoader() { // } // // private static Blade blade; // // public static void init(Blade blade) { // TaleLoader.blade = blade; // loadPlugins(); // loadThemes(); // } // // public static void loadThemes() { // String themeDir = CLASSPATH + "templates" + File.separatorChar + "themes"; // File[] dir = new File(themeDir).listFiles(); // for (File f : dir) { // if (f.isDirectory() && Files.isDirectory(Paths.get(f.getPath() + "/static"))) { // String themePath = "/templates/themes/" + f.getName(); // blade.addStatics(themePath + "/style.css", themePath + "/screenshot.png", themePath + "/static/"); // } // } // } // // public static void loadTheme(String themePath) { // blade.addStatics(themePath + "/style.css", themePath + "/screenshot.png", themePath + "/static/"); // } // // public static void loadPlugins() { // File pluginDir = new File(CLASSPATH + "plugins"); // if (pluginDir.exists() && pluginDir.isDirectory()) { // File[] plugins = pluginDir.listFiles(); // for (File plugin : plugins) { // loadPlugin(plugin); // } // } // } // // /** // * 加载某个插件jar包 // * // * @param pluginFile 插件文件 // */ // public static void loadPlugin(File pluginFile) { // try { // if (pluginFile.isFile() && pluginFile.getName().endsWith(".jar")) { // URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); // Method add = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class}); // add.setAccessible(true); // add.invoke(classLoader, pluginFile.toURI().toURL()); // // String pluginName = pluginFile.getName().substring(6); // blade.addStatics("/templates/plugins/" + pluginName + "/static/"); // } // } catch (Exception e) { // throw new RuntimeException("插件 [" + pluginFile.getName() + "] 加载失败"); // } // } // // }
import com.blade.Blade; import com.blade.security.web.csrf.CsrfMiddleware; import com.tale.bootstrap.TaleLoader;
package com.tale; /** * Tale启动类 * * @author biezhi */ public class Application { public static void main(String[] args) { Blade blade = Blade.of();
// Path: src/main/java/com/tale/bootstrap/TaleLoader.java // public final class TaleLoader { // // private TaleLoader() { // } // // private static Blade blade; // // public static void init(Blade blade) { // TaleLoader.blade = blade; // loadPlugins(); // loadThemes(); // } // // public static void loadThemes() { // String themeDir = CLASSPATH + "templates" + File.separatorChar + "themes"; // File[] dir = new File(themeDir).listFiles(); // for (File f : dir) { // if (f.isDirectory() && Files.isDirectory(Paths.get(f.getPath() + "/static"))) { // String themePath = "/templates/themes/" + f.getName(); // blade.addStatics(themePath + "/style.css", themePath + "/screenshot.png", themePath + "/static/"); // } // } // } // // public static void loadTheme(String themePath) { // blade.addStatics(themePath + "/style.css", themePath + "/screenshot.png", themePath + "/static/"); // } // // public static void loadPlugins() { // File pluginDir = new File(CLASSPATH + "plugins"); // if (pluginDir.exists() && pluginDir.isDirectory()) { // File[] plugins = pluginDir.listFiles(); // for (File plugin : plugins) { // loadPlugin(plugin); // } // } // } // // /** // * 加载某个插件jar包 // * // * @param pluginFile 插件文件 // */ // public static void loadPlugin(File pluginFile) { // try { // if (pluginFile.isFile() && pluginFile.getName().endsWith(".jar")) { // URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); // Method add = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class}); // add.setAccessible(true); // add.invoke(classLoader, pluginFile.toURI().toURL()); // // String pluginName = pluginFile.getName().substring(6); // blade.addStatics("/templates/plugins/" + pluginName + "/static/"); // } // } catch (Exception e) { // throw new RuntimeException("插件 [" + pluginFile.getName() + "] 加载失败"); // } // } // // } // Path: src/main/java/com/tale/Application.java import com.blade.Blade; import com.blade.security.web.csrf.CsrfMiddleware; import com.tale.bootstrap.TaleLoader; package com.tale; /** * Tale启动类 * * @author biezhi */ public class Application { public static void main(String[] args) { Blade blade = Blade.of();
TaleLoader.init(blade);
otale/tale
src/test/java/com/tale/test/service/ContentsServiceTest.java
// Path: src/main/java/com/tale/service/ContentsService.java // @Bean // public class ContentsService { // // @Inject // private MetasService metasService; // // /** // * 根据id或slug获取文章 // * // * @param id 唯一标识 // */ // public Contents getContents(String id) { // Contents contents = null; // if (StringKit.isNotBlank(id)) { // if (StringKit.isNumber(id)) { // contents = select().from(Contents.class).byId(id); // } else { // contents = select().from(Contents.class).where(Contents::getSlug, id).one(); // } // if (null != contents) { // return this.mapContent(contents); // } // } // return contents; // } // // /** // * 发布文章 // * // * @param contents 文章对象 // */ // public Integer publish(Contents contents) { // if (null == contents.getAuthorId()) { // throw new ValidatorException("请登录后发布文章"); // } // // contents.setContent(EmojiParser.parseToAliases(contents.getContent())); // // int time = DateKit.nowUnix(); // contents.setCreated(time); // contents.setModified(time); // contents.setHits(0); // // String tags = contents.getTags(); // String categories = contents.getCategories(); // // Integer cid = contents.save().asInt(); // // metasService.saveMetas(cid, tags, Types.TAG); // metasService.saveMetas(cid, categories, Types.CATEGORY); // // return cid; // } // // /** // * 编辑文章 // * // * @param contents 文章对象 // */ // public void updateArticle(Contents contents) { // contents.setCreated(contents.getCreated()); // contents.setModified(DateKit.nowUnix()); // contents.setContent(EmojiParser.parseToAliases(contents.getContent())); // contents.setTags(contents.getTags() != null ? contents.getTags() : ""); // contents.setCategories(contents.getCategories() != null ? contents.getCategories() : ""); // // Integer cid = contents.getCid(); // // contents.updateById(cid); // // String tags = contents.getTags(); // String categories = contents.getCategories(); // // if (null != contents.getType() && !contents.getType().equals(Types.PAGE)) { // Anima.delete().from(Relationships.class).where(Relationships::getCid, cid).execute(); // } // // metasService.saveMetas(cid, tags, Types.TAG); // metasService.saveMetas(cid, categories, Types.CATEGORY); // } // // /** // * 根据文章id删除 // * // * @param cid 文章id // */ // public void delete(int cid) { // Contents contents = this.getContents(cid + ""); // if (null != contents) { // deleteById(Contents.class, cid); // Anima.delete().from(Relationships.class).where(Relationships::getCid, cid).execute(); // Anima.delete().from(Comments.class).where(Comments::getCid, cid).execute(); // } // } // // /** // * 查询分类/标签下的文章归档 // * // * @param mid 分类、标签id // * @param page 页码 // * @param limit 每页条数 // * @return // */ // public Page<Contents> getArticles(Integer mid, int page, int limit) { // return select().bySQL(Contents.class, SQL_QUERY_ARTICLES, mid).page(page, limit); // } // // public Page<Contents> findArticles(ArticleParam articleParam) { // AnimaQuery<Contents> query = select().from(Contents.class).exclude(Contents::getContent); // // if (StringKit.isNotEmpty(articleParam.getStatus())) { // query.and(Contents::getStatus, articleParam.getStatus()); // } // // if (StringKit.isNotEmpty(articleParam.getTitle())) { // query.and(Contents::getTitle).like("%" + articleParam.getTitle() + "%"); // } // // if (StringKit.isNotEmpty(articleParam.getCategories())) { // query.and(Contents::getCategories).like("%" + articleParam.getCategories() + "%"); // } // // query.and(Contents::getType, articleParam.getType()); // query.order(articleParam.getOrderBy()); // Page<Contents> articles = query.page(articleParam.getPage(), articleParam.getLimit()); // return articles.map(this::mapContent); // } // // private Contents mapContent(Contents contents) { // if (StringKit.isNotEmpty(contents.getSlug())) { // String url = "/" + contents.getSlug(); // contents.setUrl(url.replaceAll("[/]+", "/")); // } else { // contents.setUrl("/article/" + contents.getCid()); // } // String content = contents.getContent(); // if (StringKit.isNotEmpty(content)) { // content = content.replaceAll("\\\\\"", "\\\""); // contents.setContent(content); // } // return contents; // } // } // // Path: src/test/java/com/tale/test/BaseTest.java // @RunWith(BladeTestRunner.class) // @BladeApplication(Application.class) // public abstract class BaseTest { // // }
import com.blade.ioc.annotation.Inject; import com.tale.service.ContentsService; import com.tale.test.BaseTest; import org.junit.Test;
package com.tale.test.service; /** * @author biezhi * @date 2018/6/3 */ public class ContentsServiceTest extends BaseTest { @Inject
// Path: src/main/java/com/tale/service/ContentsService.java // @Bean // public class ContentsService { // // @Inject // private MetasService metasService; // // /** // * 根据id或slug获取文章 // * // * @param id 唯一标识 // */ // public Contents getContents(String id) { // Contents contents = null; // if (StringKit.isNotBlank(id)) { // if (StringKit.isNumber(id)) { // contents = select().from(Contents.class).byId(id); // } else { // contents = select().from(Contents.class).where(Contents::getSlug, id).one(); // } // if (null != contents) { // return this.mapContent(contents); // } // } // return contents; // } // // /** // * 发布文章 // * // * @param contents 文章对象 // */ // public Integer publish(Contents contents) { // if (null == contents.getAuthorId()) { // throw new ValidatorException("请登录后发布文章"); // } // // contents.setContent(EmojiParser.parseToAliases(contents.getContent())); // // int time = DateKit.nowUnix(); // contents.setCreated(time); // contents.setModified(time); // contents.setHits(0); // // String tags = contents.getTags(); // String categories = contents.getCategories(); // // Integer cid = contents.save().asInt(); // // metasService.saveMetas(cid, tags, Types.TAG); // metasService.saveMetas(cid, categories, Types.CATEGORY); // // return cid; // } // // /** // * 编辑文章 // * // * @param contents 文章对象 // */ // public void updateArticle(Contents contents) { // contents.setCreated(contents.getCreated()); // contents.setModified(DateKit.nowUnix()); // contents.setContent(EmojiParser.parseToAliases(contents.getContent())); // contents.setTags(contents.getTags() != null ? contents.getTags() : ""); // contents.setCategories(contents.getCategories() != null ? contents.getCategories() : ""); // // Integer cid = contents.getCid(); // // contents.updateById(cid); // // String tags = contents.getTags(); // String categories = contents.getCategories(); // // if (null != contents.getType() && !contents.getType().equals(Types.PAGE)) { // Anima.delete().from(Relationships.class).where(Relationships::getCid, cid).execute(); // } // // metasService.saveMetas(cid, tags, Types.TAG); // metasService.saveMetas(cid, categories, Types.CATEGORY); // } // // /** // * 根据文章id删除 // * // * @param cid 文章id // */ // public void delete(int cid) { // Contents contents = this.getContents(cid + ""); // if (null != contents) { // deleteById(Contents.class, cid); // Anima.delete().from(Relationships.class).where(Relationships::getCid, cid).execute(); // Anima.delete().from(Comments.class).where(Comments::getCid, cid).execute(); // } // } // // /** // * 查询分类/标签下的文章归档 // * // * @param mid 分类、标签id // * @param page 页码 // * @param limit 每页条数 // * @return // */ // public Page<Contents> getArticles(Integer mid, int page, int limit) { // return select().bySQL(Contents.class, SQL_QUERY_ARTICLES, mid).page(page, limit); // } // // public Page<Contents> findArticles(ArticleParam articleParam) { // AnimaQuery<Contents> query = select().from(Contents.class).exclude(Contents::getContent); // // if (StringKit.isNotEmpty(articleParam.getStatus())) { // query.and(Contents::getStatus, articleParam.getStatus()); // } // // if (StringKit.isNotEmpty(articleParam.getTitle())) { // query.and(Contents::getTitle).like("%" + articleParam.getTitle() + "%"); // } // // if (StringKit.isNotEmpty(articleParam.getCategories())) { // query.and(Contents::getCategories).like("%" + articleParam.getCategories() + "%"); // } // // query.and(Contents::getType, articleParam.getType()); // query.order(articleParam.getOrderBy()); // Page<Contents> articles = query.page(articleParam.getPage(), articleParam.getLimit()); // return articles.map(this::mapContent); // } // // private Contents mapContent(Contents contents) { // if (StringKit.isNotEmpty(contents.getSlug())) { // String url = "/" + contents.getSlug(); // contents.setUrl(url.replaceAll("[/]+", "/")); // } else { // contents.setUrl("/article/" + contents.getCid()); // } // String content = contents.getContent(); // if (StringKit.isNotEmpty(content)) { // content = content.replaceAll("\\\\\"", "\\\""); // contents.setContent(content); // } // return contents; // } // } // // Path: src/test/java/com/tale/test/BaseTest.java // @RunWith(BladeTestRunner.class) // @BladeApplication(Application.class) // public abstract class BaseTest { // // } // Path: src/test/java/com/tale/test/service/ContentsServiceTest.java import com.blade.ioc.annotation.Inject; import com.tale.service.ContentsService; import com.tale.test.BaseTest; import org.junit.Test; package com.tale.test.service; /** * @author biezhi * @date 2018/6/3 */ public class ContentsServiceTest extends BaseTest { @Inject
private ContentsService contentsService;
otale/tale
src/test/java/com/tale/test/service/OptionsServiceTest.java
// Path: src/main/java/com/tale/service/OptionsService.java // @Bean // public class OptionsService { // // /** // * 保存配置 // * // * @param key 配置key // * @param value 配置值 // */ // public void saveOption(String key, String value) { // if (StringKit.isNotBlank(key) && StringKit.isNotBlank(value)) { // Options options = new Options(); // options.setName(key); // // long count = select().from(Options.class).where(Options::getName, key).count(); // // if (count == 0) { // options = new Options(); // options.setName(key); // options.setValue(value); // options.save(); // } else { // options = new Options(); // options.setValue(value); // options.updateById(key); // } // } // } // // /** // * 获取系统配置 // */ // public Map<String, String> getOptions() { // Map<String, String> options = new HashMap<>(); // AnimaQuery<Options> animaQuery = select().from(Options.class); // List<Options> optionsList = animaQuery.all(); // if (null != optionsList) { // optionsList.forEach(option -> options.put(option.getName(), option.getValue())); // } // return options; // } // // public String getOption(String key) { // Options options = select().from(Options.class).byId(key); // if (null != options) { // return options.getValue(); // } // return null; // } // // /** // * 根据key删除配置项 // * // * @param key 配置key // */ // public void deleteOption(String key) { // if (StringKit.isNotBlank(key)) { // delete().from(Options.class).where(Options::getName).like(key + "%").execute(); // } // } // } // // Path: src/test/java/com/tale/test/BaseTest.java // @RunWith(BladeTestRunner.class) // @BladeApplication(Application.class) // public abstract class BaseTest { // // }
import com.blade.ioc.annotation.Inject; import com.tale.service.OptionsService; import com.tale.test.BaseTest; import org.junit.Assert; import org.junit.Test;
package com.tale.test.service; /** * @author biezhi * @date 2018/6/3 */ public class OptionsServiceTest extends BaseTest { @Inject
// Path: src/main/java/com/tale/service/OptionsService.java // @Bean // public class OptionsService { // // /** // * 保存配置 // * // * @param key 配置key // * @param value 配置值 // */ // public void saveOption(String key, String value) { // if (StringKit.isNotBlank(key) && StringKit.isNotBlank(value)) { // Options options = new Options(); // options.setName(key); // // long count = select().from(Options.class).where(Options::getName, key).count(); // // if (count == 0) { // options = new Options(); // options.setName(key); // options.setValue(value); // options.save(); // } else { // options = new Options(); // options.setValue(value); // options.updateById(key); // } // } // } // // /** // * 获取系统配置 // */ // public Map<String, String> getOptions() { // Map<String, String> options = new HashMap<>(); // AnimaQuery<Options> animaQuery = select().from(Options.class); // List<Options> optionsList = animaQuery.all(); // if (null != optionsList) { // optionsList.forEach(option -> options.put(option.getName(), option.getValue())); // } // return options; // } // // public String getOption(String key) { // Options options = select().from(Options.class).byId(key); // if (null != options) { // return options.getValue(); // } // return null; // } // // /** // * 根据key删除配置项 // * // * @param key 配置key // */ // public void deleteOption(String key) { // if (StringKit.isNotBlank(key)) { // delete().from(Options.class).where(Options::getName).like(key + "%").execute(); // } // } // } // // Path: src/test/java/com/tale/test/BaseTest.java // @RunWith(BladeTestRunner.class) // @BladeApplication(Application.class) // public abstract class BaseTest { // // } // Path: src/test/java/com/tale/test/service/OptionsServiceTest.java import com.blade.ioc.annotation.Inject; import com.tale.service.OptionsService; import com.tale.test.BaseTest; import org.junit.Assert; import org.junit.Test; package com.tale.test.service; /** * @author biezhi * @date 2018/6/3 */ public class OptionsServiceTest extends BaseTest { @Inject
private OptionsService optionsService;
otale/tale
src/main/java/com/tale/service/OptionsService.java
// Path: src/main/java/com/tale/model/entity/Options.java // @Data // @Table(name = "t_options", pk = "name") // @EqualsAndHashCode(callSuper = true) // public class Options extends Model { // // /** // * 配置键 // */ // private String name; // // /** // * 配置值 // */ // private String value; // // /** // * 配置描述 // */ // private String description; // // }
import com.blade.ioc.annotation.Bean; import com.blade.kit.StringKit; import com.tale.model.entity.Options; import io.github.biezhi.anima.core.AnimaQuery; import java.util.HashMap; import java.util.List; import java.util.Map; import static io.github.biezhi.anima.Anima.delete; import static io.github.biezhi.anima.Anima.select;
package com.tale.service; /** * 配置Service * * @author biezhi * @since 1.3.1 */ @Bean public class OptionsService { /** * 保存配置 * * @param key 配置key * @param value 配置值 */ public void saveOption(String key, String value) { if (StringKit.isNotBlank(key) && StringKit.isNotBlank(value)) {
// Path: src/main/java/com/tale/model/entity/Options.java // @Data // @Table(name = "t_options", pk = "name") // @EqualsAndHashCode(callSuper = true) // public class Options extends Model { // // /** // * 配置键 // */ // private String name; // // /** // * 配置值 // */ // private String value; // // /** // * 配置描述 // */ // private String description; // // } // Path: src/main/java/com/tale/service/OptionsService.java import com.blade.ioc.annotation.Bean; import com.blade.kit.StringKit; import com.tale.model.entity.Options; import io.github.biezhi.anima.core.AnimaQuery; import java.util.HashMap; import java.util.List; import java.util.Map; import static io.github.biezhi.anima.Anima.delete; import static io.github.biezhi.anima.Anima.select; package com.tale.service; /** * 配置Service * * @author biezhi * @since 1.3.1 */ @Bean public class OptionsService { /** * 保存配置 * * @param key 配置key * @param value 配置值 */ public void saveOption(String key, String value) { if (StringKit.isNotBlank(key) && StringKit.isNotBlank(value)) {
Options options = new Options();
otale/tale
src/test/java/com/tale/test/service/CommentsServiceTest.java
// Path: src/main/java/com/tale/service/CommentsService.java // @Bean // public class CommentsService { // // /** // * 保存评论 // * // * @param comments // */ // public void saveComment(Comments comments) { // comments.setAuthor(TaleUtils.cleanXSS(comments.getAuthor())); // comments.setContent(TaleUtils.cleanXSS(comments.getContent())); // // comments.setAuthor(EmojiParser.parseToAliases(comments.getAuthor())); // comments.setContent(EmojiParser.parseToAliases(comments.getContent())); // // Contents contents = select().from(Contents.class).byId(comments.getCid()); // if (null == contents) { // throw new ValidatorException("不存在的文章"); // } // try { // comments.setOwnerId(contents.getAuthorId()); // comments.setAuthorId(null == comments.getAuthorId() ? 0 : comments.getAuthorId()); // comments.setCreated(DateKit.nowUnix()); // comments.setParent(null == comments.getCoid() ? 0 : comments.getCoid()); // comments.setCoid(null); // comments.save(); // // new Contents().set(Contents::getCommentsNum, contents.getCommentsNum() + 1).updateById(contents.getCid()); // } catch (Exception e) { // throw e; // } // } // // /** // * 删除评论,暂时没用 // * // * @param coid // * @param cid // * @throws Exception // */ // public void delete(Integer coid, Integer cid) { // Anima.delete().from(Comments.class).deleteById(coid); // // Contents contents = select().from(Contents.class).byId(cid); // if (null != contents && contents.getCommentsNum() > 0) { // update().from(Contents.class).set(Contents::getCommentsNum, contents.getCommentsNum() - 1).updateById(cid); // } // } // // /** // * 获取文章下的评论 // * // * @param cid // * @param page // * @param limit // * @return // */ // public Page<Comment> getComments(Integer cid, int page, int limit) { // if (null == cid) { // return null; // } // // Page<Comments> commentsPage = select().from(Comments.class) // .where(Comments::getCid, cid).and(Comments::getParent, 0) // .and(Comments::getStatus, COMMENT_APPROVED) // .order(Comments::getCoid, OrderBy.DESC).page(page, limit); // // return commentsPage.map(this::apply); // } // // /** // * 获取文章下的评论统计 // * // * @param cid 文章ID // */ // public long getCommentCount(Integer cid) { // if (null == cid) { // return 0; // } // return select().from(Comments.class).where(Comments::getCid, cid).count(); // } // // /** // * 获取该评论下的追加评论 // * // * @param coid // * @return // */ // private void getChildren(List<Comments> list, Integer coid) { // List<Comments> cms = select().from(Comments.class).where(Comments::getParent, coid).order(Comments::getCoid, OrderBy.ASC).all(); // if (null != cms) { // list.addAll(cms); // cms.forEach(c -> getChildren(list, c.getCoid())); // } // } // // private Comment apply(Comments parent) { // Comment comment = new Comment(parent); // List<Comments> children = new ArrayList<>(); // getChildren(children, comment.getCoid()); // comment.setChildren(children); // if (BladeKit.isNotEmpty(children)) { // comment.setLevels(1); // } // return comment; // } // // public Page<Comments> findComments(CommentParam commentParam) { // return select().from(Comments.class) // .order(Comments::getCoid, OrderBy.DESC) // .page(commentParam.getPage(), commentParam.getLimit()); // } // // } // // Path: src/test/java/com/tale/test/BaseTest.java // @RunWith(BladeTestRunner.class) // @BladeApplication(Application.class) // public abstract class BaseTest { // // }
import com.blade.ioc.annotation.Inject; import com.tale.service.CommentsService; import com.tale.test.BaseTest; import org.junit.Test;
package com.tale.test.service; /** * @author biezhi * @date 2018/6/3 */ public class CommentsServiceTest extends BaseTest { @Inject
// Path: src/main/java/com/tale/service/CommentsService.java // @Bean // public class CommentsService { // // /** // * 保存评论 // * // * @param comments // */ // public void saveComment(Comments comments) { // comments.setAuthor(TaleUtils.cleanXSS(comments.getAuthor())); // comments.setContent(TaleUtils.cleanXSS(comments.getContent())); // // comments.setAuthor(EmojiParser.parseToAliases(comments.getAuthor())); // comments.setContent(EmojiParser.parseToAliases(comments.getContent())); // // Contents contents = select().from(Contents.class).byId(comments.getCid()); // if (null == contents) { // throw new ValidatorException("不存在的文章"); // } // try { // comments.setOwnerId(contents.getAuthorId()); // comments.setAuthorId(null == comments.getAuthorId() ? 0 : comments.getAuthorId()); // comments.setCreated(DateKit.nowUnix()); // comments.setParent(null == comments.getCoid() ? 0 : comments.getCoid()); // comments.setCoid(null); // comments.save(); // // new Contents().set(Contents::getCommentsNum, contents.getCommentsNum() + 1).updateById(contents.getCid()); // } catch (Exception e) { // throw e; // } // } // // /** // * 删除评论,暂时没用 // * // * @param coid // * @param cid // * @throws Exception // */ // public void delete(Integer coid, Integer cid) { // Anima.delete().from(Comments.class).deleteById(coid); // // Contents contents = select().from(Contents.class).byId(cid); // if (null != contents && contents.getCommentsNum() > 0) { // update().from(Contents.class).set(Contents::getCommentsNum, contents.getCommentsNum() - 1).updateById(cid); // } // } // // /** // * 获取文章下的评论 // * // * @param cid // * @param page // * @param limit // * @return // */ // public Page<Comment> getComments(Integer cid, int page, int limit) { // if (null == cid) { // return null; // } // // Page<Comments> commentsPage = select().from(Comments.class) // .where(Comments::getCid, cid).and(Comments::getParent, 0) // .and(Comments::getStatus, COMMENT_APPROVED) // .order(Comments::getCoid, OrderBy.DESC).page(page, limit); // // return commentsPage.map(this::apply); // } // // /** // * 获取文章下的评论统计 // * // * @param cid 文章ID // */ // public long getCommentCount(Integer cid) { // if (null == cid) { // return 0; // } // return select().from(Comments.class).where(Comments::getCid, cid).count(); // } // // /** // * 获取该评论下的追加评论 // * // * @param coid // * @return // */ // private void getChildren(List<Comments> list, Integer coid) { // List<Comments> cms = select().from(Comments.class).where(Comments::getParent, coid).order(Comments::getCoid, OrderBy.ASC).all(); // if (null != cms) { // list.addAll(cms); // cms.forEach(c -> getChildren(list, c.getCoid())); // } // } // // private Comment apply(Comments parent) { // Comment comment = new Comment(parent); // List<Comments> children = new ArrayList<>(); // getChildren(children, comment.getCoid()); // comment.setChildren(children); // if (BladeKit.isNotEmpty(children)) { // comment.setLevels(1); // } // return comment; // } // // public Page<Comments> findComments(CommentParam commentParam) { // return select().from(Comments.class) // .order(Comments::getCoid, OrderBy.DESC) // .page(commentParam.getPage(), commentParam.getLimit()); // } // // } // // Path: src/test/java/com/tale/test/BaseTest.java // @RunWith(BladeTestRunner.class) // @BladeApplication(Application.class) // public abstract class BaseTest { // // } // Path: src/test/java/com/tale/test/service/CommentsServiceTest.java import com.blade.ioc.annotation.Inject; import com.tale.service.CommentsService; import com.tale.test.BaseTest; import org.junit.Test; package com.tale.test.service; /** * @author biezhi * @date 2018/6/3 */ public class CommentsServiceTest extends BaseTest { @Inject
private CommentsService commentsService;
otale/tale
src/main/java/com/tale/model/dto/Archive.java
// Path: src/main/java/com/tale/model/entity/Contents.java // @Data // @Table(name = "t_contents", pk = "cid") // public class Contents extends Model { // // /** // * 文章表主键 // */ // private Integer cid; // // /** // * 文章标题 // */ // private String title; // // /** // * 文章缩略名 // */ // private String slug; // // /** // * 文章创建时间戳 // */ // private Integer created; // // /** // * 文章修改时间戳 // */ // private Integer modified; // // /** // * 文章内容 // */ // private String content; // // /** // * 文章创建用户 // */ // private Integer authorId; // // /** // * 文章点击次数 // */ // private Integer hits; // // /** // * 文章类型: PAGE、POST // */ // private String type; // // /** // * 内容类型,markdown或者html // */ // private String fmtType; // // /** // * 文章缩略图 // */ // private String thumbImg; // // /** // * 标签列表 // */ // private String tags; // // /** // * 分类列表 // */ // private String categories; // // /** // * 内容状态 // */ // private String status; // // /** // * 内容所属评论数 // */ // private Integer commentsNum; // // /** // * 是否允许评论 // */ // private Boolean allowComment; // // /** // * 是否允许ping // */ // private Boolean allowPing; // // /** // * 允许出现在Feed中 // */ // private Boolean allowFeed; // // @Ignore // private String url; // }
import com.tale.model.entity.Contents; import io.github.biezhi.anima.Model; import lombok.Data; import java.util.Date; import java.util.List;
package com.tale.model.dto; /** * 文章归档 * <p> * Created by biezhi on 2017/2/23. */ @Data public class Archive extends Model { private String dateStr; private Date date; private String count;
// Path: src/main/java/com/tale/model/entity/Contents.java // @Data // @Table(name = "t_contents", pk = "cid") // public class Contents extends Model { // // /** // * 文章表主键 // */ // private Integer cid; // // /** // * 文章标题 // */ // private String title; // // /** // * 文章缩略名 // */ // private String slug; // // /** // * 文章创建时间戳 // */ // private Integer created; // // /** // * 文章修改时间戳 // */ // private Integer modified; // // /** // * 文章内容 // */ // private String content; // // /** // * 文章创建用户 // */ // private Integer authorId; // // /** // * 文章点击次数 // */ // private Integer hits; // // /** // * 文章类型: PAGE、POST // */ // private String type; // // /** // * 内容类型,markdown或者html // */ // private String fmtType; // // /** // * 文章缩略图 // */ // private String thumbImg; // // /** // * 标签列表 // */ // private String tags; // // /** // * 分类列表 // */ // private String categories; // // /** // * 内容状态 // */ // private String status; // // /** // * 内容所属评论数 // */ // private Integer commentsNum; // // /** // * 是否允许评论 // */ // private Boolean allowComment; // // /** // * 是否允许ping // */ // private Boolean allowPing; // // /** // * 允许出现在Feed中 // */ // private Boolean allowFeed; // // @Ignore // private String url; // } // Path: src/main/java/com/tale/model/dto/Archive.java import com.tale.model.entity.Contents; import io.github.biezhi.anima.Model; import lombok.Data; import java.util.Date; import java.util.List; package com.tale.model.dto; /** * 文章归档 * <p> * Created by biezhi on 2017/2/23. */ @Data public class Archive extends Model { private String dateStr; private Date date; private String count;
private List<Contents> articles;
otale/tale
src/main/java/com/tale/bootstrap/TaleLoader.java
// Path: src/main/java/com/tale/bootstrap/TaleConst.java // public static final String CLASSPATH = new File(AdminApiController.class.getResource("/").getPath()).getPath() + File.separatorChar;
import com.blade.Blade; import java.io.File; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Paths; import static com.tale.bootstrap.TaleConst.CLASSPATH;
package com.tale.bootstrap; /** * Created by biezhi on 2017/3/1. */ public final class TaleLoader { private TaleLoader() { } private static Blade blade; public static void init(Blade blade) { TaleLoader.blade = blade; loadPlugins(); loadThemes(); } public static void loadThemes() {
// Path: src/main/java/com/tale/bootstrap/TaleConst.java // public static final String CLASSPATH = new File(AdminApiController.class.getResource("/").getPath()).getPath() + File.separatorChar; // Path: src/main/java/com/tale/bootstrap/TaleLoader.java import com.blade.Blade; import java.io.File; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Paths; import static com.tale.bootstrap.TaleConst.CLASSPATH; package com.tale.bootstrap; /** * Created by biezhi on 2017/3/1. */ public final class TaleLoader { private TaleLoader() { } private static Blade blade; public static void init(Blade blade) { TaleLoader.blade = blade; loadPlugins(); loadThemes(); } public static void loadThemes() {
String themeDir = CLASSPATH + "templates" + File.separatorChar + "themes";
otale/tale
src/main/java/com/tale/model/dto/Comment.java
// Path: src/main/java/com/tale/model/entity/Comments.java // @Data // @Table(name = "t_comments", pk = "coid") // public class Comments extends Model { // // // comment表主键 // private Integer coid; // // // post表主键,关联字段 // private Integer cid; // // // 评论生成时的GMT unix时间戳 // private Integer created; // // // 评论作者 // private String author; // // // 评论所属用户id // private Integer authorId; // // // 评论所属内容作者id // private Integer ownerId; // // // 评论者邮件 // private String mail; // // // 评论者网址 // private String url; // // // 评论者ip地址 // private String ip; // // // 评论者客户端 // private String agent; // // // 评论内容 // private String content; // // // 评论类型 // private String type; // // // 评论状态 // private String status; // // // 父级评论 // private Integer parent; // // }
import com.tale.model.entity.Comments; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import java.util.List;
package com.tale.model.dto; /** * Created by biezhi on 2017/2/24. */ @Data @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true)
// Path: src/main/java/com/tale/model/entity/Comments.java // @Data // @Table(name = "t_comments", pk = "coid") // public class Comments extends Model { // // // comment表主键 // private Integer coid; // // // post表主键,关联字段 // private Integer cid; // // // 评论生成时的GMT unix时间戳 // private Integer created; // // // 评论作者 // private String author; // // // 评论所属用户id // private Integer authorId; // // // 评论所属内容作者id // private Integer ownerId; // // // 评论者邮件 // private String mail; // // // 评论者网址 // private String url; // // // 评论者ip地址 // private String ip; // // // 评论者客户端 // private String agent; // // // 评论内容 // private String content; // // // 评论类型 // private String type; // // // 评论状态 // private String status; // // // 父级评论 // private Integer parent; // // } // Path: src/main/java/com/tale/model/dto/Comment.java import com.tale.model.entity.Comments; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import java.util.List; package com.tale.model.dto; /** * Created by biezhi on 2017/2/24. */ @Data @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class Comment extends Comments {
dsl-platform/lagom-postgres
wonders-impl/src/main/java/worldwonders/wonders/impl/WondersServiceModule.java
// Path: wonders-api/src/main/java/worldwonders/wonders/api/WondersService.java // public interface WondersService extends Service { // ServiceCall<NotUsed, NotUsed, List<Wonder>> findAll(); // // ServiceCall<NotUsed, NotUsed, List<String>> getWonderTypes(); // // ServiceCall<NotUsed, Wonder, NotUsed> makeWonder(); // // ServiceCall<NotUsed, NewComment, NotUsed> newComment(); // // @Override // default Descriptor descriptor() { // return named("wonders-service").with( // restCall(Method.GET, "/wonders", findAll()), // restCall(Method.GET, "/wonderTypes", getWonderTypes()), // restCall(Method.POST, "/wonder", makeWonder()), // restCall(Method.POST, "/new-comment", newComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(WondersService.class)); // } // }
import com.google.inject.AbstractModule; import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; import worldwonders.wonders.api.WondersService;
package worldwonders.wonders.impl; public class WondersServiceModule extends AbstractModule implements ServiceGuiceSupport { @Override protected void configure() {
// Path: wonders-api/src/main/java/worldwonders/wonders/api/WondersService.java // public interface WondersService extends Service { // ServiceCall<NotUsed, NotUsed, List<Wonder>> findAll(); // // ServiceCall<NotUsed, NotUsed, List<String>> getWonderTypes(); // // ServiceCall<NotUsed, Wonder, NotUsed> makeWonder(); // // ServiceCall<NotUsed, NewComment, NotUsed> newComment(); // // @Override // default Descriptor descriptor() { // return named("wonders-service").with( // restCall(Method.GET, "/wonders", findAll()), // restCall(Method.GET, "/wonderTypes", getWonderTypes()), // restCall(Method.POST, "/wonder", makeWonder()), // restCall(Method.POST, "/new-comment", newComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(WondersService.class)); // } // } // Path: wonders-impl/src/main/java/worldwonders/wonders/impl/WondersServiceModule.java import com.google.inject.AbstractModule; import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; import worldwonders.wonders.api.WondersService; package worldwonders.wonders.impl; public class WondersServiceModule extends AbstractModule implements ServiceGuiceSupport { @Override protected void configure() {
bindServices(serviceBinding(WondersService.class, WondersServiceImpl.class));
dsl-platform/lagom-postgres
wonders-api/src/main/java/worldwonders/wonders/api/WondersService.java
// Path: dsl-json-lagom/src/main/java/org/revenj/json/lagom/DslJsonLagomSerialization.java // public class DslJsonLagomSerialization { // public static <T extends com.lightbend.lagom.javadsl.api.Service> PMap<Type, MessageSerializer<?,?>> optimizeSerializersFor(final Class<T> service) { // PMap<Type, MessageSerializer<?,?>> result = HashTreePMap.empty(); // final DslJsonSerialization serialization = new DslJsonSerialization(null, Optional.empty()); // // final Method[] serviceMethods = service.getMethods(); // for (final Method serviceMethod : serviceMethods) { // if (serviceMethod.getReturnType() != ServiceCall.class) continue; // final ParameterizedType genericReturnType = (ParameterizedType) serviceMethod.getGenericReturnType(); // final Type[] arguments = genericReturnType.getActualTypeArguments(); // // for (int i = 1; i <= 2; i ++) { // final Type type = arguments[i]; // if (type == NotUsed.class) continue; // // if (result.containsKey(type)) continue; // result = result.plus(type, new DslJsonMessageSerializer<>(type, serialization)); // } // } // return result; // } // }
import static com.lightbend.lagom.javadsl.api.Service.named; import static com.lightbend.lagom.javadsl.api.Service.restCall; import java.util.List; import org.revenj.json.lagom.DslJsonLagomSerialization; import com.lightbend.lagom.javadsl.api.Descriptor; import com.lightbend.lagom.javadsl.api.Service; import com.lightbend.lagom.javadsl.api.ServiceCall; import com.lightbend.lagom.javadsl.api.transport.Method; import akka.NotUsed; import worldwonders.wonders.NewComment; import worldwonders.wonders.Wonder;
package worldwonders.wonders.api; public interface WondersService extends Service { ServiceCall<NotUsed, NotUsed, List<Wonder>> findAll(); ServiceCall<NotUsed, NotUsed, List<String>> getWonderTypes(); ServiceCall<NotUsed, Wonder, NotUsed> makeWonder(); ServiceCall<NotUsed, NewComment, NotUsed> newComment(); @Override default Descriptor descriptor() { return named("wonders-service").with( restCall(Method.GET, "/wonders", findAll()), restCall(Method.GET, "/wonderTypes", getWonderTypes()), restCall(Method.POST, "/wonder", makeWonder()), restCall(Method.POST, "/new-comment", newComment()) ).withAutoAcl(true)
// Path: dsl-json-lagom/src/main/java/org/revenj/json/lagom/DslJsonLagomSerialization.java // public class DslJsonLagomSerialization { // public static <T extends com.lightbend.lagom.javadsl.api.Service> PMap<Type, MessageSerializer<?,?>> optimizeSerializersFor(final Class<T> service) { // PMap<Type, MessageSerializer<?,?>> result = HashTreePMap.empty(); // final DslJsonSerialization serialization = new DslJsonSerialization(null, Optional.empty()); // // final Method[] serviceMethods = service.getMethods(); // for (final Method serviceMethod : serviceMethods) { // if (serviceMethod.getReturnType() != ServiceCall.class) continue; // final ParameterizedType genericReturnType = (ParameterizedType) serviceMethod.getGenericReturnType(); // final Type[] arguments = genericReturnType.getActualTypeArguments(); // // for (int i = 1; i <= 2; i ++) { // final Type type = arguments[i]; // if (type == NotUsed.class) continue; // // if (result.containsKey(type)) continue; // result = result.plus(type, new DslJsonMessageSerializer<>(type, serialization)); // } // } // return result; // } // } // Path: wonders-api/src/main/java/worldwonders/wonders/api/WondersService.java import static com.lightbend.lagom.javadsl.api.Service.named; import static com.lightbend.lagom.javadsl.api.Service.restCall; import java.util.List; import org.revenj.json.lagom.DslJsonLagomSerialization; import com.lightbend.lagom.javadsl.api.Descriptor; import com.lightbend.lagom.javadsl.api.Service; import com.lightbend.lagom.javadsl.api.ServiceCall; import com.lightbend.lagom.javadsl.api.transport.Method; import akka.NotUsed; import worldwonders.wonders.NewComment; import worldwonders.wonders.Wonder; package worldwonders.wonders.api; public interface WondersService extends Service { ServiceCall<NotUsed, NotUsed, List<Wonder>> findAll(); ServiceCall<NotUsed, NotUsed, List<String>> getWonderTypes(); ServiceCall<NotUsed, Wonder, NotUsed> makeWonder(); ServiceCall<NotUsed, NewComment, NotUsed> newComment(); @Override default Descriptor descriptor() { return named("wonders-service").with( restCall(Method.GET, "/wonders", findAll()), restCall(Method.GET, "/wonderTypes", getWonderTypes()), restCall(Method.POST, "/wonder", makeWonder()), restCall(Method.POST, "/new-comment", newComment()) ).withAutoAcl(true)
.replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(WondersService.class));
dsl-platform/lagom-postgres
comments-impl/src/main/java/worldwonders/comments/impl/CommentsServiceModule.java
// Path: comments-api/src/main/java/worldwonders/comments/api/CommentsService.java // public interface CommentsService extends Service { // ServiceCall<NotUsed, NotUsed, List<Comment>> findAll(); // // ServiceCall<String, NotUsed, List<Comment>> findForTopic(); // // ServiceCall<NotUsed, Comment, NotUsed> postComment(); // // @Override // default Descriptor descriptor() { // return named("comments-service").with( // restCall(Method.GET, "/comments", findAll()), // restCall(Method.GET, "/comments/:topic", findForTopic()), // restCall(Method.POST, "/comment", postComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(CommentsService.class)); // } // } // // Path: wonders-api/src/main/java/worldwonders/wonders/api/WondersService.java // public interface WondersService extends Service { // ServiceCall<NotUsed, NotUsed, List<Wonder>> findAll(); // // ServiceCall<NotUsed, NotUsed, List<String>> getWonderTypes(); // // ServiceCall<NotUsed, Wonder, NotUsed> makeWonder(); // // ServiceCall<NotUsed, NewComment, NotUsed> newComment(); // // @Override // default Descriptor descriptor() { // return named("wonders-service").with( // restCall(Method.GET, "/wonders", findAll()), // restCall(Method.GET, "/wonderTypes", getWonderTypes()), // restCall(Method.POST, "/wonder", makeWonder()), // restCall(Method.POST, "/new-comment", newComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(WondersService.class)); // } // }
import com.google.inject.AbstractModule; import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; import worldwonders.comments.api.CommentsService; import worldwonders.wonders.api.WondersService;
package worldwonders.comments.impl; public class CommentsServiceModule extends AbstractModule implements ServiceGuiceSupport { @Override protected void configure() {
// Path: comments-api/src/main/java/worldwonders/comments/api/CommentsService.java // public interface CommentsService extends Service { // ServiceCall<NotUsed, NotUsed, List<Comment>> findAll(); // // ServiceCall<String, NotUsed, List<Comment>> findForTopic(); // // ServiceCall<NotUsed, Comment, NotUsed> postComment(); // // @Override // default Descriptor descriptor() { // return named("comments-service").with( // restCall(Method.GET, "/comments", findAll()), // restCall(Method.GET, "/comments/:topic", findForTopic()), // restCall(Method.POST, "/comment", postComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(CommentsService.class)); // } // } // // Path: wonders-api/src/main/java/worldwonders/wonders/api/WondersService.java // public interface WondersService extends Service { // ServiceCall<NotUsed, NotUsed, List<Wonder>> findAll(); // // ServiceCall<NotUsed, NotUsed, List<String>> getWonderTypes(); // // ServiceCall<NotUsed, Wonder, NotUsed> makeWonder(); // // ServiceCall<NotUsed, NewComment, NotUsed> newComment(); // // @Override // default Descriptor descriptor() { // return named("wonders-service").with( // restCall(Method.GET, "/wonders", findAll()), // restCall(Method.GET, "/wonderTypes", getWonderTypes()), // restCall(Method.POST, "/wonder", makeWonder()), // restCall(Method.POST, "/new-comment", newComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(WondersService.class)); // } // } // Path: comments-impl/src/main/java/worldwonders/comments/impl/CommentsServiceModule.java import com.google.inject.AbstractModule; import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; import worldwonders.comments.api.CommentsService; import worldwonders.wonders.api.WondersService; package worldwonders.comments.impl; public class CommentsServiceModule extends AbstractModule implements ServiceGuiceSupport { @Override protected void configure() {
bindClient(WondersService.class);
dsl-platform/lagom-postgres
comments-impl/src/main/java/worldwonders/comments/impl/CommentsServiceModule.java
// Path: comments-api/src/main/java/worldwonders/comments/api/CommentsService.java // public interface CommentsService extends Service { // ServiceCall<NotUsed, NotUsed, List<Comment>> findAll(); // // ServiceCall<String, NotUsed, List<Comment>> findForTopic(); // // ServiceCall<NotUsed, Comment, NotUsed> postComment(); // // @Override // default Descriptor descriptor() { // return named("comments-service").with( // restCall(Method.GET, "/comments", findAll()), // restCall(Method.GET, "/comments/:topic", findForTopic()), // restCall(Method.POST, "/comment", postComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(CommentsService.class)); // } // } // // Path: wonders-api/src/main/java/worldwonders/wonders/api/WondersService.java // public interface WondersService extends Service { // ServiceCall<NotUsed, NotUsed, List<Wonder>> findAll(); // // ServiceCall<NotUsed, NotUsed, List<String>> getWonderTypes(); // // ServiceCall<NotUsed, Wonder, NotUsed> makeWonder(); // // ServiceCall<NotUsed, NewComment, NotUsed> newComment(); // // @Override // default Descriptor descriptor() { // return named("wonders-service").with( // restCall(Method.GET, "/wonders", findAll()), // restCall(Method.GET, "/wonderTypes", getWonderTypes()), // restCall(Method.POST, "/wonder", makeWonder()), // restCall(Method.POST, "/new-comment", newComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(WondersService.class)); // } // }
import com.google.inject.AbstractModule; import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; import worldwonders.comments.api.CommentsService; import worldwonders.wonders.api.WondersService;
package worldwonders.comments.impl; public class CommentsServiceModule extends AbstractModule implements ServiceGuiceSupport { @Override protected void configure() { bindClient(WondersService.class);
// Path: comments-api/src/main/java/worldwonders/comments/api/CommentsService.java // public interface CommentsService extends Service { // ServiceCall<NotUsed, NotUsed, List<Comment>> findAll(); // // ServiceCall<String, NotUsed, List<Comment>> findForTopic(); // // ServiceCall<NotUsed, Comment, NotUsed> postComment(); // // @Override // default Descriptor descriptor() { // return named("comments-service").with( // restCall(Method.GET, "/comments", findAll()), // restCall(Method.GET, "/comments/:topic", findForTopic()), // restCall(Method.POST, "/comment", postComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(CommentsService.class)); // } // } // // Path: wonders-api/src/main/java/worldwonders/wonders/api/WondersService.java // public interface WondersService extends Service { // ServiceCall<NotUsed, NotUsed, List<Wonder>> findAll(); // // ServiceCall<NotUsed, NotUsed, List<String>> getWonderTypes(); // // ServiceCall<NotUsed, Wonder, NotUsed> makeWonder(); // // ServiceCall<NotUsed, NewComment, NotUsed> newComment(); // // @Override // default Descriptor descriptor() { // return named("wonders-service").with( // restCall(Method.GET, "/wonders", findAll()), // restCall(Method.GET, "/wonderTypes", getWonderTypes()), // restCall(Method.POST, "/wonder", makeWonder()), // restCall(Method.POST, "/new-comment", newComment()) // ).withAutoAcl(true) // .replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(WondersService.class)); // } // } // Path: comments-impl/src/main/java/worldwonders/comments/impl/CommentsServiceModule.java import com.google.inject.AbstractModule; import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; import worldwonders.comments.api.CommentsService; import worldwonders.wonders.api.WondersService; package worldwonders.comments.impl; public class CommentsServiceModule extends AbstractModule implements ServiceGuiceSupport { @Override protected void configure() { bindClient(WondersService.class);
bindServices(serviceBinding(CommentsService.class, CommentsServiceImpl.class));
dsl-platform/lagom-postgres
storage-impl/src/main/java/worldwonders/storage/impl/StorageServiceModule.java
// Path: storage-api/src/main/java/worldwonders/storage/api/StorageService.java // public interface StorageService extends Service { // ServiceCall<String, NotUsed, byte[]> downloadImage(); // // @Override // default Descriptor descriptor() { // return named("storage-service").with( // restCall(Method.GET, "/image/:url", downloadImage()) // .withResponseSerializer(new ByteArrayResponseSerializer()) // ).withAutoAcl(true); // } // }
import com.google.inject.AbstractModule; import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; import worldwonders.storage.api.StorageService;
package worldwonders.storage.impl; public class StorageServiceModule extends AbstractModule implements ServiceGuiceSupport { @Override protected void configure() {
// Path: storage-api/src/main/java/worldwonders/storage/api/StorageService.java // public interface StorageService extends Service { // ServiceCall<String, NotUsed, byte[]> downloadImage(); // // @Override // default Descriptor descriptor() { // return named("storage-service").with( // restCall(Method.GET, "/image/:url", downloadImage()) // .withResponseSerializer(new ByteArrayResponseSerializer()) // ).withAutoAcl(true); // } // } // Path: storage-impl/src/main/java/worldwonders/storage/impl/StorageServiceModule.java import com.google.inject.AbstractModule; import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; import worldwonders.storage.api.StorageService; package worldwonders.storage.impl; public class StorageServiceModule extends AbstractModule implements ServiceGuiceSupport { @Override protected void configure() {
bindServices(serviceBinding(StorageService.class, StorageServiceImpl.class));
dsl-platform/lagom-postgres
comments-api/src/main/java/worldwonders/comments/api/CommentsService.java
// Path: dsl-json-lagom/src/main/java/org/revenj/json/lagom/DslJsonLagomSerialization.java // public class DslJsonLagomSerialization { // public static <T extends com.lightbend.lagom.javadsl.api.Service> PMap<Type, MessageSerializer<?,?>> optimizeSerializersFor(final Class<T> service) { // PMap<Type, MessageSerializer<?,?>> result = HashTreePMap.empty(); // final DslJsonSerialization serialization = new DslJsonSerialization(null, Optional.empty()); // // final Method[] serviceMethods = service.getMethods(); // for (final Method serviceMethod : serviceMethods) { // if (serviceMethod.getReturnType() != ServiceCall.class) continue; // final ParameterizedType genericReturnType = (ParameterizedType) serviceMethod.getGenericReturnType(); // final Type[] arguments = genericReturnType.getActualTypeArguments(); // // for (int i = 1; i <= 2; i ++) { // final Type type = arguments[i]; // if (type == NotUsed.class) continue; // // if (result.containsKey(type)) continue; // result = result.plus(type, new DslJsonMessageSerializer<>(type, serialization)); // } // } // return result; // } // }
import static com.lightbend.lagom.javadsl.api.Service.named; import static com.lightbend.lagom.javadsl.api.Service.restCall; import java.util.List; import org.revenj.json.lagom.DslJsonLagomSerialization; import com.lightbend.lagom.javadsl.api.Descriptor; import com.lightbend.lagom.javadsl.api.Service; import com.lightbend.lagom.javadsl.api.ServiceCall; import com.lightbend.lagom.javadsl.api.transport.Method; import akka.NotUsed; import worldwonders.comments.Comment;
package worldwonders.comments.api; public interface CommentsService extends Service { ServiceCall<NotUsed, NotUsed, List<Comment>> findAll(); ServiceCall<String, NotUsed, List<Comment>> findForTopic(); ServiceCall<NotUsed, Comment, NotUsed> postComment(); @Override default Descriptor descriptor() { return named("comments-service").with( restCall(Method.GET, "/comments", findAll()), restCall(Method.GET, "/comments/:topic", findForTopic()), restCall(Method.POST, "/comment", postComment()) ).withAutoAcl(true)
// Path: dsl-json-lagom/src/main/java/org/revenj/json/lagom/DslJsonLagomSerialization.java // public class DslJsonLagomSerialization { // public static <T extends com.lightbend.lagom.javadsl.api.Service> PMap<Type, MessageSerializer<?,?>> optimizeSerializersFor(final Class<T> service) { // PMap<Type, MessageSerializer<?,?>> result = HashTreePMap.empty(); // final DslJsonSerialization serialization = new DslJsonSerialization(null, Optional.empty()); // // final Method[] serviceMethods = service.getMethods(); // for (final Method serviceMethod : serviceMethods) { // if (serviceMethod.getReturnType() != ServiceCall.class) continue; // final ParameterizedType genericReturnType = (ParameterizedType) serviceMethod.getGenericReturnType(); // final Type[] arguments = genericReturnType.getActualTypeArguments(); // // for (int i = 1; i <= 2; i ++) { // final Type type = arguments[i]; // if (type == NotUsed.class) continue; // // if (result.containsKey(type)) continue; // result = result.plus(type, new DslJsonMessageSerializer<>(type, serialization)); // } // } // return result; // } // } // Path: comments-api/src/main/java/worldwonders/comments/api/CommentsService.java import static com.lightbend.lagom.javadsl.api.Service.named; import static com.lightbend.lagom.javadsl.api.Service.restCall; import java.util.List; import org.revenj.json.lagom.DslJsonLagomSerialization; import com.lightbend.lagom.javadsl.api.Descriptor; import com.lightbend.lagom.javadsl.api.Service; import com.lightbend.lagom.javadsl.api.ServiceCall; import com.lightbend.lagom.javadsl.api.transport.Method; import akka.NotUsed; import worldwonders.comments.Comment; package worldwonders.comments.api; public interface CommentsService extends Service { ServiceCall<NotUsed, NotUsed, List<Comment>> findAll(); ServiceCall<String, NotUsed, List<Comment>> findForTopic(); ServiceCall<NotUsed, Comment, NotUsed> postComment(); @Override default Descriptor descriptor() { return named("comments-service").with( restCall(Method.GET, "/comments", findAll()), restCall(Method.GET, "/comments/:topic", findForTopic()), restCall(Method.POST, "/comment", postComment()) ).withAutoAcl(true)
.replaceAllMessageSerializers(DslJsonLagomSerialization.optimizeSerializersFor(CommentsService.class));
redfin/validity
src/main/java/com/redfin/validity/verifiers/objects/VerifiableInteger.java
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // }
import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier;
/* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Integer subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableInteger<X extends Throwable> extends AbstractVerifiableComparableNumber<Integer, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Integer ZERO = 0; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableInteger} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // } // Path: src/main/java/com/redfin/validity/verifiers/objects/VerifiableInteger.java import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier; /* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Integer subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableInteger<X extends Throwable> extends AbstractVerifiableComparableNumber<Integer, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Integer ZERO = 0; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableInteger} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
public VerifiableInteger(FailedValidationExecutor<X> failedValidationExecutor,
redfin/validity
src/main/java/com/redfin/validity/verifiers/objects/VerifiableDouble.java
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // }
import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier;
/* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Double subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableDouble<X extends Throwable> extends AbstractVerifiableComparableNumber<Double, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Double ZERO = 0.0; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableDouble} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // } // Path: src/main/java/com/redfin/validity/verifiers/objects/VerifiableDouble.java import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier; /* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Double subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableDouble<X extends Throwable> extends AbstractVerifiableComparableNumber<Double, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Double ZERO = 0.0; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableDouble} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
public VerifiableDouble(FailedValidationExecutor<X> failedValidationExecutor,
redfin/validity
src/main/java/com/redfin/validity/verifiers/objects/VerifiableLong.java
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // }
import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier;
/* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Long subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableLong<X extends Throwable> extends AbstractVerifiableComparableNumber<Long, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Long ZERO = 0L; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableLong} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // } // Path: src/main/java/com/redfin/validity/verifiers/objects/VerifiableLong.java import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier; /* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Long subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableLong<X extends Throwable> extends AbstractVerifiableComparableNumber<Long, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Long ZERO = 0L; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableLong} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
public VerifiableLong(FailedValidationExecutor<X> failedValidationExecutor,
redfin/validity
src/main/java/com/redfin/validity/verifiers/objects/VerifiableByte.java
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // }
import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier;
/* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Byte subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableByte<X extends Throwable> extends AbstractVerifiableComparableNumber<Byte, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Byte ZERO = 0; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableByte} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // } // Path: src/main/java/com/redfin/validity/verifiers/objects/VerifiableByte.java import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier; /* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Byte subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableByte<X extends Throwable> extends AbstractVerifiableComparableNumber<Byte, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Byte ZERO = 0; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableByte} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
public VerifiableByte(FailedValidationExecutor<X> failedValidationExecutor,
redfin/validity
src/main/java/com/redfin/validity/verifiers/objects/VerifiableFloat.java
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // }
import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier;
/* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Float subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableFloat<X extends Throwable> extends AbstractVerifiableComparableNumber<Float, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Float ZERO = 0F; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableFloat} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // } // Path: src/main/java/com/redfin/validity/verifiers/objects/VerifiableFloat.java import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier; /* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Float subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableFloat<X extends Throwable> extends AbstractVerifiableComparableNumber<Float, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Float ZERO = 0F; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableFloat} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
public VerifiableFloat(FailedValidationExecutor<X> failedValidationExecutor,
redfin/validity
src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // }
import com.redfin.validity.FailedValidationExecutor; import java.util.function.Supplier;
/* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers; /** * Base class for verifiable objects that implement the Comparable interface and Number. * * @param <T> the type of the subject being validated. * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> extends AbstractVerifiableComparable<T, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java import com.redfin.validity.FailedValidationExecutor; import java.util.function.Supplier; /* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers; /** * Base class for verifiable objects that implement the Comparable interface and Number. * * @param <T> the type of the subject being validated. * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> extends AbstractVerifiableComparable<T, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor,
redfin/validity
src/main/java/com/redfin/validity/ValidityUtils.java
// Path: src/main/java/com/redfin/validity/predicates/AbstractDescriptivePredicate.java // public abstract class AbstractDescriptivePredicate { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Constants // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * The String token that must be part of the description for // * an {@link AbstractDescriptivePredicate} instance. This is stored // * in the predicate to allow for composition of predicates and then // * converted by the {@link #toString()} to give a nice, human-readable // * string value for the predicate. For example, given a predicate with // * the following description:<br> // * <br> // * {@code "null != {}"}<br> // * <br> // * The toString would return:<br> // * <br> // * {@code "t -> null != t"}<br> // * <br> // * The value of "t" is from the the {@link #VARIABLE} value. // */ // public static final String TOKEN = "{}"; // // /** // * The String variable name that will replace all instances of the {@link #TOKEN} // * String when the {@link #toString()} method is called on a descriptive predicate. // */ // public static final String VARIABLE = "t"; // // private static final String NEGATE_FORMAT = "!(%s)"; // private static final String AND_FORMAT = "(%s) && (%s)"; // private static final String OR_FORMAT = "(%s) || (%s)"; // private static final String TO_STRING_PREFIX = "t -> "; // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Fields // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // private final String description; // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractDescriptivePredicate} instance with the given description.<br> // * <br> // * Note that the predicate description must contain the {@link #TOKEN} and should not // * contain the {@link #VARIABLE} as a variable name already in the description as that // * can lead to confusion. // * // * @param description the String description for this predicate instance. // * May not be null and must contain the TOKEN. // * @throws NullPointerException if description is null. // * @throws IllegalArgumentException if description does not contain {@link #TOKEN}. // */ // public AbstractDescriptivePredicate(String description) { // if (null == description) { // throw new NullPointerException(ValidityUtils.nullArgumentMessage("description")); // } // if (!description.contains(TOKEN)) { // throw new IllegalArgumentException("A descriptive predicate must have the token in the description."); // } // this.description = description; // } // // /** // * @return the formatted new description of the negated version of // * this description. // */ // protected final String getNegateDescription() { // return String.format(NEGATE_FORMAT, description); // } // // /** // * @param otherDescription the String description of the other predicate. // * @return the formatted new description of the AND composition of this // * description and the other description. // */ // protected final String getAndDescription(String otherDescription) { // return String.format(AND_FORMAT, description, otherDescription); // } // // /** // * @param otherDescription the String description of the other predicate. // * @return the formatted new description of the OR composition of this // * description and the other description. // */ // protected final String getOrDescription(String otherDescription) { // return String.format(OR_FORMAT, description, otherDescription); // } // // @Override // public final String toString() { // return TO_STRING_PREFIX + description.replace(TOKEN, "t"); // } // // /** // * @throws UnsupportedOperationException always. // * @deprecated descriptive predicate objects cannot be tested for equality. // */ // @Deprecated // @Override // public final boolean equals(Object obj) { // throw new UnsupportedOperationException("This class cannot be treated as a value and does not support the Object equals method"); // } // // /** // * @throws UnsupportedOperationException always. // * @deprecated descriptive predicate objects cannot be hashed. // */ // @Deprecated // @Override // public final int hashCode() { // throw new UnsupportedOperationException("This class cannot be treated as a value and does not support the Object hashCode method"); // } // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Static Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Describe the other object (assuming it to be a predicate type). // * // * @param other the object to be described as a predicate. // * May not be null. // * @return the String description (as a predicate) of other. // * @throws NullPointerException if other is null. // */ // protected static String describeOther(Object other) { // if (null == other) { // throw new NullPointerException(ValidityUtils.nullArgumentMessage("other")); // } // if (other instanceof AbstractDescriptivePredicate) { // return ((AbstractDescriptivePredicate) other).description; // } // return ValidityUtils.unknownPredicatePrefix() + other.toString(); // } // }
import com.redfin.validity.predicates.AbstractDescriptivePredicate; import java.util.Arrays; import java.util.function.DoublePredicate; import java.util.function.IntPredicate; import java.util.function.LongPredicate; import java.util.function.Predicate;
} /** * @param value the value to convert into a String. * * @return a String representation of the given value. */ public static String describe(LongPredicate value) { return describePredicate(value); } /** * @param value the value to convert into a String. * * @return a String representation of the given value. */ public static String describe(DoublePredicate value) { return describePredicate(value); } /** * @param value the value to convert into a String. * * @return a String representation of the given value. */ public static String describe(Predicate<?> value) { return describePredicate(value); } private static String describePredicate(Object obj) {
// Path: src/main/java/com/redfin/validity/predicates/AbstractDescriptivePredicate.java // public abstract class AbstractDescriptivePredicate { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Constants // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * The String token that must be part of the description for // * an {@link AbstractDescriptivePredicate} instance. This is stored // * in the predicate to allow for composition of predicates and then // * converted by the {@link #toString()} to give a nice, human-readable // * string value for the predicate. For example, given a predicate with // * the following description:<br> // * <br> // * {@code "null != {}"}<br> // * <br> // * The toString would return:<br> // * <br> // * {@code "t -> null != t"}<br> // * <br> // * The value of "t" is from the the {@link #VARIABLE} value. // */ // public static final String TOKEN = "{}"; // // /** // * The String variable name that will replace all instances of the {@link #TOKEN} // * String when the {@link #toString()} method is called on a descriptive predicate. // */ // public static final String VARIABLE = "t"; // // private static final String NEGATE_FORMAT = "!(%s)"; // private static final String AND_FORMAT = "(%s) && (%s)"; // private static final String OR_FORMAT = "(%s) || (%s)"; // private static final String TO_STRING_PREFIX = "t -> "; // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Fields // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // private final String description; // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractDescriptivePredicate} instance with the given description.<br> // * <br> // * Note that the predicate description must contain the {@link #TOKEN} and should not // * contain the {@link #VARIABLE} as a variable name already in the description as that // * can lead to confusion. // * // * @param description the String description for this predicate instance. // * May not be null and must contain the TOKEN. // * @throws NullPointerException if description is null. // * @throws IllegalArgumentException if description does not contain {@link #TOKEN}. // */ // public AbstractDescriptivePredicate(String description) { // if (null == description) { // throw new NullPointerException(ValidityUtils.nullArgumentMessage("description")); // } // if (!description.contains(TOKEN)) { // throw new IllegalArgumentException("A descriptive predicate must have the token in the description."); // } // this.description = description; // } // // /** // * @return the formatted new description of the negated version of // * this description. // */ // protected final String getNegateDescription() { // return String.format(NEGATE_FORMAT, description); // } // // /** // * @param otherDescription the String description of the other predicate. // * @return the formatted new description of the AND composition of this // * description and the other description. // */ // protected final String getAndDescription(String otherDescription) { // return String.format(AND_FORMAT, description, otherDescription); // } // // /** // * @param otherDescription the String description of the other predicate. // * @return the formatted new description of the OR composition of this // * description and the other description. // */ // protected final String getOrDescription(String otherDescription) { // return String.format(OR_FORMAT, description, otherDescription); // } // // @Override // public final String toString() { // return TO_STRING_PREFIX + description.replace(TOKEN, "t"); // } // // /** // * @throws UnsupportedOperationException always. // * @deprecated descriptive predicate objects cannot be tested for equality. // */ // @Deprecated // @Override // public final boolean equals(Object obj) { // throw new UnsupportedOperationException("This class cannot be treated as a value and does not support the Object equals method"); // } // // /** // * @throws UnsupportedOperationException always. // * @deprecated descriptive predicate objects cannot be hashed. // */ // @Deprecated // @Override // public final int hashCode() { // throw new UnsupportedOperationException("This class cannot be treated as a value and does not support the Object hashCode method"); // } // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Static Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Describe the other object (assuming it to be a predicate type). // * // * @param other the object to be described as a predicate. // * May not be null. // * @return the String description (as a predicate) of other. // * @throws NullPointerException if other is null. // */ // protected static String describeOther(Object other) { // if (null == other) { // throw new NullPointerException(ValidityUtils.nullArgumentMessage("other")); // } // if (other instanceof AbstractDescriptivePredicate) { // return ((AbstractDescriptivePredicate) other).description; // } // return ValidityUtils.unknownPredicatePrefix() + other.toString(); // } // } // Path: src/main/java/com/redfin/validity/ValidityUtils.java import com.redfin.validity.predicates.AbstractDescriptivePredicate; import java.util.Arrays; import java.util.function.DoublePredicate; import java.util.function.IntPredicate; import java.util.function.LongPredicate; import java.util.function.Predicate; } /** * @param value the value to convert into a String. * * @return a String representation of the given value. */ public static String describe(LongPredicate value) { return describePredicate(value); } /** * @param value the value to convert into a String. * * @return a String representation of the given value. */ public static String describe(DoublePredicate value) { return describePredicate(value); } /** * @param value the value to convert into a String. * * @return a String representation of the given value. */ public static String describe(Predicate<?> value) { return describePredicate(value); } private static String describePredicate(Object obj) {
if (obj instanceof AbstractDescriptivePredicate) {
redfin/validity
src/main/java/com/redfin/validity/verifiers/objects/VerifiableShort.java
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // }
import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier;
/* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Short subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableShort<X extends Throwable> extends AbstractVerifiableComparableNumber<Short, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Short ZERO = 0; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableShort} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
// Path: src/main/java/com/redfin/validity/FailedValidationExecutor.java // public interface FailedValidationExecutor<X extends Throwable> { // // /** // * Signals the {@link FailedValidationExecutor} that the validation of the subject // * failed. // * // * @param expected the String representation of the expected condition. // * May not be null. // * @param subject the test subject. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message supplied by the validation user. // * May not be null. // * @param <T> the type of subject. // * // * @throws NullPointerException if expected or messageSupplier are null. // * @throws X always, unless expected is null. // */ // <T> void fail(String expected, // T subject, // Supplier<String> messageSupplier) throws X; // } // // Path: src/main/java/com/redfin/validity/verifiers/AbstractVerifiableComparableNumber.java // public abstract class AbstractVerifiableComparableNumber<T extends Number & Comparable<T>, X extends Throwable> // extends AbstractVerifiableComparable<T, X> { // // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Instance Methods // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // /** // * Create a new {@link AbstractVerifiableComparableNumber} instance with the given values. // * // * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called // * on validation failure. // * May not be null. // * @param subject the subject to be validated. // * May be null. // * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. // * May not be null. // * // * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. // */ // public AbstractVerifiableComparableNumber(FailedValidationExecutor<X> failedValidationExecutor, // T subject, // Supplier<String> messageSupplier) { // super(failedValidationExecutor, subject, messageSupplier); // } // // /** // * @return the value of Zero for the implementing // * subtype of number. // */ // protected abstract T getZero(); // // /** // * @return the subject if it is comparable to zero. // * // * @throws X if the subject is not comparable to zero. // */ // public T isZero() throws X { // return isComparableTo(getZero()); // } // // /** // * @return the subject if it is not comparable to zero. // * // * @throws X if the subject is comparable to zero. // */ // public T isNotZero() throws X { // return isNotComparableTo(getZero()); // } // // /** // * @return the subject if it is greater than zero. // * // * @throws X if the subject is less than or equal to zero. // */ // public T isStrictlyPositive() throws X { // return isGreaterThan(getZero()); // } // // /** // * @return the subject if it is less than zero. // * // * @throws X if the subject is greater than or equal to zero. // */ // public T isStrictlyNegative() throws X { // return isLessThan(getZero()); // } // } // Path: src/main/java/com/redfin/validity/verifiers/objects/VerifiableShort.java import com.redfin.validity.FailedValidationExecutor; import com.redfin.validity.verifiers.AbstractVerifiableComparableNumber; import java.util.function.Supplier; /* * Copyright: (c) 2016 Redfin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redfin.validity.verifiers.objects; /** * Concrete class for verifying Short subjects. * * @param <X> the type of {@link Throwable} to be thrown on validation failure. */ public final class VerifiableShort<X extends Throwable> extends AbstractVerifiableComparableNumber<Short, X> { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Constants // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static final Short ZERO = 0; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Instance Methods // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a new {@link VerifiableShort} instance with the given values. * * @param failedValidationExecutor the {@link FailedValidationExecutor} to be called * on validation failure. * May not be null. * @param subject the subject to be validated. * May be null. * @param messageSupplier the {@link Supplier} of the String custom message to pre-pend a failure with. * May not be null. * * @throws NullPointerException if failedValidationExecutor or messageSupplier are null. */
public VerifiableShort(FailedValidationExecutor<X> failedValidationExecutor,
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/PrintingTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> D newInstance(Class<D> type) { // return Instances.newInstance(type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> void registerTag(Class<D> type, String tag) { // Serialization.registerTag(type, tag); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.newInstance; import static com.github.rschmitt.dynamicobject.DynamicObject.registerTag; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class PrintingTest { static Tagged emptyTagged; static Untagged emptyUntagged; static Tagged nestedTagged; static Untagged nestedUntagged; @BeforeAll public static void setup() {
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> D newInstance(Class<D> type) { // return Instances.newInstance(type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> void registerTag(Class<D> type, String tag) { // Serialization.registerTag(type, tag); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/PrintingTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.newInstance; import static com.github.rschmitt.dynamicobject.DynamicObject.registerTag; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class PrintingTest { static Tagged emptyTagged; static Untagged emptyUntagged; static Tagged nestedTagged; static Untagged nestedUntagged; @BeforeAll public static void setup() {
registerTag(Tagged.class, "Tagged");
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/PrintingTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> D newInstance(Class<D> type) { // return Instances.newInstance(type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> void registerTag(Class<D> type, String tag) { // Serialization.registerTag(type, tag); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.newInstance; import static com.github.rschmitt.dynamicobject.DynamicObject.registerTag; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class PrintingTest { static Tagged emptyTagged; static Untagged emptyUntagged; static Tagged nestedTagged; static Untagged nestedUntagged; @BeforeAll public static void setup() { registerTag(Tagged.class, "Tagged");
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> D newInstance(Class<D> type) { // return Instances.newInstance(type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> void registerTag(Class<D> type, String tag) { // Serialization.registerTag(type, tag); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/PrintingTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.newInstance; import static com.github.rschmitt.dynamicobject.DynamicObject.registerTag; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class PrintingTest { static Tagged emptyTagged; static Untagged emptyUntagged; static Tagged nestedTagged; static Untagged nestedUntagged; @BeforeAll public static void setup() { registerTag(Tagged.class, "Tagged");
emptyTagged = newInstance(Tagged.class);
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/PrintingTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> D newInstance(Class<D> type) { // return Instances.newInstance(type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> void registerTag(Class<D> type, String tag) { // Serialization.registerTag(type, tag); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.newInstance; import static com.github.rschmitt.dynamicobject.DynamicObject.registerTag; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class PrintingTest { static Tagged emptyTagged; static Untagged emptyUntagged; static Tagged nestedTagged; static Untagged nestedUntagged; @BeforeAll public static void setup() { registerTag(Tagged.class, "Tagged"); emptyTagged = newInstance(Tagged.class); emptyUntagged = newInstance(Untagged.class); nestedTagged = emptyTagged.tagged(emptyTagged).untagged(emptyUntagged); nestedUntagged = emptyUntagged.tagged(emptyTagged).untagged(emptyUntagged); } @Test public void toStringTest() {
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> D newInstance(Class<D> type) { // return Instances.newInstance(type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> void registerTag(Class<D> type, String tag) { // Serialization.registerTag(type, tag); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/PrintingTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.newInstance; import static com.github.rschmitt.dynamicobject.DynamicObject.registerTag; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class PrintingTest { static Tagged emptyTagged; static Untagged emptyUntagged; static Tagged nestedTagged; static Untagged nestedUntagged; @BeforeAll public static void setup() { registerTag(Tagged.class, "Tagged"); emptyTagged = newInstance(Tagged.class); emptyUntagged = newInstance(Untagged.class); nestedTagged = emptyTagged.tagged(emptyTagged).untagged(emptyUntagged); nestedUntagged = emptyUntagged.tagged(emptyTagged).untagged(emptyUntagged); } @Test public void toStringTest() {
assertEquivalent("#Tagged{}", emptyTagged.toString());
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/PrintingTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> D newInstance(Class<D> type) { // return Instances.newInstance(type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> void registerTag(Class<D> type, String tag) { // Serialization.registerTag(type, tag); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.newInstance; import static com.github.rschmitt.dynamicobject.DynamicObject.registerTag; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class PrintingTest { static Tagged emptyTagged; static Untagged emptyUntagged; static Tagged nestedTagged; static Untagged nestedUntagged; @BeforeAll public static void setup() { registerTag(Tagged.class, "Tagged"); emptyTagged = newInstance(Tagged.class); emptyUntagged = newInstance(Untagged.class); nestedTagged = emptyTagged.tagged(emptyTagged).untagged(emptyUntagged); nestedUntagged = emptyUntagged.tagged(emptyTagged).untagged(emptyUntagged); } @Test public void toStringTest() { assertEquivalent("#Tagged{}", emptyTagged.toString()); assertEquivalent("{}", emptyUntagged.toString()); assertEquivalent("#Tagged{:untagged {}, :tagged #Tagged{}}", nestedTagged.toString()); assertEquivalent("{:untagged {}, :tagged #Tagged{}}", nestedUntagged.toString()); } @Test public void toFormattedStringTest() { assertEquivalent("#Tagged{}", emptyTagged.toFormattedString()); assertEquivalent("{}", emptyUntagged.toFormattedString()); assertEquivalent("#Tagged{:untagged {}, :tagged #Tagged{}}", nestedTagged.toFormattedString()); assertEquivalent("{:untagged {}, :tagged #Tagged{}}", nestedUntagged.toFormattedString()); } @Test public void serializeTest() {
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> D newInstance(Class<D> type) { // return Instances.newInstance(type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <D extends DynamicObject<D>> void registerTag(Class<D> type, String tag) { // Serialization.registerTag(type, tag); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/PrintingTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.newInstance; import static com.github.rschmitt.dynamicobject.DynamicObject.registerTag; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class PrintingTest { static Tagged emptyTagged; static Untagged emptyUntagged; static Tagged nestedTagged; static Untagged nestedUntagged; @BeforeAll public static void setup() { registerTag(Tagged.class, "Tagged"); emptyTagged = newInstance(Tagged.class); emptyUntagged = newInstance(Untagged.class); nestedTagged = emptyTagged.tagged(emptyTagged).untagged(emptyUntagged); nestedUntagged = emptyUntagged.tagged(emptyTagged).untagged(emptyUntagged); } @Test public void toStringTest() { assertEquivalent("#Tagged{}", emptyTagged.toString()); assertEquivalent("{}", emptyUntagged.toString()); assertEquivalent("#Tagged{:untagged {}, :tagged #Tagged{}}", nestedTagged.toString()); assertEquivalent("{:untagged {}, :tagged #Tagged{}}", nestedUntagged.toString()); } @Test public void toFormattedStringTest() { assertEquivalent("#Tagged{}", emptyTagged.toFormattedString()); assertEquivalent("{}", emptyUntagged.toFormattedString()); assertEquivalent("#Tagged{:untagged {}, :tagged #Tagged{}}", nestedTagged.toFormattedString()); assertEquivalent("{:untagged {}, :tagged #Tagged{}}", nestedUntagged.toFormattedString()); } @Test public void serializeTest() {
assertEquivalent("#Tagged{}", serialize(emptyTagged));
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/PrimitiveTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class PrimitiveTest { private static final String Edn = "{:i 4, :d 3.14, :f 3.14, :lng 1234567890, :shrt 4, :bool true, :c \\newline, :b 127}";
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/PrimitiveTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class PrimitiveTest { private static final String Edn = "{:i 4, :d 3.14, :f 3.14, :lng 1234567890, :shrt 4, :bool true, :c \\newline, :b 127}";
private static final Unboxed Unboxed = deserialize(Edn, Unboxed.class);
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/PrimitiveTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test;
@Test public void unboxedBuilders() { Unboxed unboxed = DynamicObject.newInstance(Unboxed.class) .i(4) .d(3.14) .f((float) 3.14) .lng(1234567890L) .shrt((short) 4) .bool(true) .c('\n') .b((byte)127); assertEquals(Unboxed, unboxed); } @Test public void unboxedNullBuilders() { String edn = "{:b nil, :c nil, :bool nil, :shrt nil, :lng nil, :f nil, :d nil, :i nil}"; Boxed boxed = DynamicObject.newInstance(Boxed.class) .i(null) .d(null) .f(null) .lng(null) .shrt(null) .bool(null) .c(null) .b(null); assertEquals(boxed, deserialize(edn, Boxed.class));
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/PrimitiveTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @Test public void unboxedBuilders() { Unboxed unboxed = DynamicObject.newInstance(Unboxed.class) .i(4) .d(3.14) .f((float) 3.14) .lng(1234567890L) .shrt((short) 4) .bool(true) .c('\n') .b((byte)127); assertEquals(Unboxed, unboxed); } @Test public void unboxedNullBuilders() { String edn = "{:b nil, :c nil, :bool nil, :shrt nil, :lng nil, :f nil, :d nil, :i nil}"; Boxed boxed = DynamicObject.newInstance(Boxed.class) .i(null) .d(null) .f(null) .lng(null) .shrt(null) .bool(null) .c(null) .b(null); assertEquals(boxed, deserialize(edn, Boxed.class));
assertEquivalent(edn, serialize(boxed));
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/PrimitiveTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test;
@Test public void unboxedBuilders() { Unboxed unboxed = DynamicObject.newInstance(Unboxed.class) .i(4) .d(3.14) .f((float) 3.14) .lng(1234567890L) .shrt((short) 4) .bool(true) .c('\n') .b((byte)127); assertEquals(Unboxed, unboxed); } @Test public void unboxedNullBuilders() { String edn = "{:b nil, :c nil, :bool nil, :shrt nil, :lng nil, :f nil, :d nil, :i nil}"; Boxed boxed = DynamicObject.newInstance(Boxed.class) .i(null) .d(null) .f(null) .lng(null) .shrt(null) .bool(null) .c(null) .b(null); assertEquals(boxed, deserialize(edn, Boxed.class));
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/PrimitiveTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @Test public void unboxedBuilders() { Unboxed unboxed = DynamicObject.newInstance(Unboxed.class) .i(4) .d(3.14) .f((float) 3.14) .lng(1234567890L) .shrt((short) 4) .bool(true) .c('\n') .b((byte)127); assertEquals(Unboxed, unboxed); } @Test public void unboxedNullBuilders() { String edn = "{:b nil, :c nil, :bool nil, :shrt nil, :lng nil, :f nil, :d nil, :i nil}"; Boxed boxed = DynamicObject.newInstance(Boxed.class) .i(null) .d(null) .f(null) .lng(null) .shrt(null) .bool(null) .c(null) .b(null); assertEquals(boxed, deserialize(edn, Boxed.class));
assertEquivalent(edn, serialize(boxed));
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/DefaultReaderTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // }
import clojure.java.api.Clojure; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.HashMap; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows;
package com.github.rschmitt.dynamicobject; @SuppressWarnings("rawtypes") public class DefaultReaderTest { @Test public void testUnknownReader() { String edn = "#some-namespace/some-record-name{:key :value}"; Object obj = DynamicObject.deserialize(edn, Object.class); Unknown unknown = (Unknown) obj; assertEquals("some-namespace/some-record-name", unknown.getTag()); assertEquals(Clojure.read("{:key :value}"), unknown.getElement());
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/DefaultReaderTest.java import clojure.java.api.Clojure; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.HashMap; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; package com.github.rschmitt.dynamicobject; @SuppressWarnings("rawtypes") public class DefaultReaderTest { @Test public void testUnknownReader() { String edn = "#some-namespace/some-record-name{:key :value}"; Object obj = DynamicObject.deserialize(edn, Object.class); Unknown unknown = (Unknown) obj; assertEquals("some-namespace/some-record-name", unknown.getTag()); assertEquals(Clojure.read("{:key :value}"), unknown.getElement());
assertEquals(serialize(unknown), edn);
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/StreamingTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> Stream<T> deserializeStream(PushbackReader streamReader, Class<T> type) { // return EdnSerialization.deserializeStream(streamReader, type); // }
import clojure.java.api.Clojure; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.PushbackReader; import java.io.StringReader; import java.util.Iterator; import java.util.List; import java.util.stream.Stream; import static com.github.rschmitt.dynamicobject.DynamicObject.deserializeStream; import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; import static org.junit.jupiter.api.Assertions.*;
package com.github.rschmitt.dynamicobject; @SuppressWarnings("rawtypes") public class StreamingTest { @Test public void iteratorTest() { String edn = "{:x 1} {:x 2}"; PushbackReader reader = new PushbackReader(new StringReader(edn));
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> Stream<T> deserializeStream(PushbackReader streamReader, Class<T> type) { // return EdnSerialization.deserializeStream(streamReader, type); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/StreamingTest.java import clojure.java.api.Clojure; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.PushbackReader; import java.io.StringReader; import java.util.Iterator; import java.util.List; import java.util.stream.Stream; import static com.github.rschmitt.dynamicobject.DynamicObject.deserializeStream; import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; import static org.junit.jupiter.api.Assertions.*; package com.github.rschmitt.dynamicobject; @SuppressWarnings("rawtypes") public class StreamingTest { @Test public void iteratorTest() { String edn = "{:x 1} {:x 2}"; PushbackReader reader = new PushbackReader(new StringReader(edn));
Iterator<StreamingType> iterator = deserializeStream(reader, StreamingType.class).iterator();
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/DiffTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import java.util.List; import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class DiffTest { @BeforeEach public void setup() { DynamicObject.registerTag(Diffable.class, "D"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(Diffable.class); } @Test public void union() {
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/DiffTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import java.util.List; import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class DiffTest { @BeforeEach public void setup() { DynamicObject.registerTag(Diffable.class, "D"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(Diffable.class); } @Test public void union() {
Diffable a = deserialize("#D{:a \"a\", :b \"b\"}", Diffable.class);
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/DiffTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import java.util.List; import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class DiffTest { @BeforeEach public void setup() { DynamicObject.registerTag(Diffable.class, "D"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(Diffable.class); } @Test public void union() { Diffable a = deserialize("#D{:a \"a\", :b \"b\"}", Diffable.class); Diffable b = deserialize("#D{:a \"a\", :b \"b\", :c \"c\"}", Diffable.class); Diffable c = a.intersect(b); assertEquals(c, a); assertNotEquals(c, b);
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/DiffTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import java.util.List; import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class DiffTest { @BeforeEach public void setup() { DynamicObject.registerTag(Diffable.class, "D"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(Diffable.class); } @Test public void union() { Diffable a = deserialize("#D{:a \"a\", :b \"b\"}", Diffable.class); Diffable b = deserialize("#D{:a \"a\", :b \"b\", :c \"c\"}", Diffable.class); Diffable c = a.intersect(b); assertEquals(c, a); assertNotEquals(c, b);
assertEquivalent("#D{:a \"a\", :b \"b\"}", serialize(c));
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/DiffTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import java.util.List; import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class DiffTest { @BeforeEach public void setup() { DynamicObject.registerTag(Diffable.class, "D"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(Diffable.class); } @Test public void union() { Diffable a = deserialize("#D{:a \"a\", :b \"b\"}", Diffable.class); Diffable b = deserialize("#D{:a \"a\", :b \"b\", :c \"c\"}", Diffable.class); Diffable c = a.intersect(b); assertEquals(c, a); assertNotEquals(c, b);
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/DiffTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import java.util.List; import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class DiffTest { @BeforeEach public void setup() { DynamicObject.registerTag(Diffable.class, "D"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(Diffable.class); } @Test public void union() { Diffable a = deserialize("#D{:a \"a\", :b \"b\"}", Diffable.class); Diffable b = deserialize("#D{:a \"a\", :b \"b\", :c \"c\"}", Diffable.class); Diffable c = a.intersect(b); assertEquals(c, a); assertNotEquals(c, b);
assertEquivalent("#D{:a \"a\", :b \"b\"}", serialize(c));
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/MapTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // }
import clojure.lang.EdnReader; import clojure.lang.PersistentHashMap; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse;
package com.github.rschmitt.dynamicobject; @SuppressWarnings("unchecked") public class MapTest { static final String SimpleEdn = "{:str \"expected value\", :i 4, :d 3.14}"; static final String NestedEdn = format("{:version 1, :simple %s}", SimpleEdn); static final String TaggedEdn = format("#eo%s", NestedEdn); @BeforeEach public void setup() { DynamicObject.registerTag(EmptyObject.class, "eo"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(EmptyObject.class); } @Test public void getMapReturnsBackingMap() {
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/MapTest.java import clojure.lang.EdnReader; import clojure.lang.PersistentHashMap; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; package com.github.rschmitt.dynamicobject; @SuppressWarnings("unchecked") public class MapTest { static final String SimpleEdn = "{:str \"expected value\", :i 4, :d 3.14}"; static final String NestedEdn = format("{:version 1, :simple %s}", SimpleEdn); static final String TaggedEdn = format("#eo%s", NestedEdn); @BeforeEach public void setup() { DynamicObject.registerTag(EmptyObject.class, "eo"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(EmptyObject.class); } @Test public void getMapReturnsBackingMap() {
EmptyObject object = deserialize(TaggedEdn, EmptyObject.class);
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/MapTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // }
import clojure.lang.EdnReader; import clojure.lang.PersistentHashMap; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse;
@BeforeEach public void setup() { DynamicObject.registerTag(EmptyObject.class, "eo"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(EmptyObject.class); } @Test public void getMapReturnsBackingMap() { EmptyObject object = deserialize(TaggedEdn, EmptyObject.class); Object map = EdnReader.readString(NestedEdn, PersistentHashMap.EMPTY); assertEquals(map, object.getMap()); binaryRoundTrip(object); } @Test public void unknownFieldsAreConsideredForEquality() { EmptyObject obj1 = deserialize(SimpleEdn, EmptyObject.class); EmptyObject obj2 = deserialize(NestedEdn, EmptyObject.class); assertFalse(obj1.equals(obj2)); binaryRoundTrip(obj1); binaryRoundTrip(obj2); } @Test public void unknownFieldsAreSerialized() { EmptyObject nestedObj = deserialize(TaggedEdn, EmptyObject.class);
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/MapTest.java import clojure.lang.EdnReader; import clojure.lang.PersistentHashMap; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @BeforeEach public void setup() { DynamicObject.registerTag(EmptyObject.class, "eo"); } @AfterEach public void teardown() { DynamicObject.deregisterTag(EmptyObject.class); } @Test public void getMapReturnsBackingMap() { EmptyObject object = deserialize(TaggedEdn, EmptyObject.class); Object map = EdnReader.readString(NestedEdn, PersistentHashMap.EMPTY); assertEquals(map, object.getMap()); binaryRoundTrip(object); } @Test public void unknownFieldsAreConsideredForEquality() { EmptyObject obj1 = deserialize(SimpleEdn, EmptyObject.class); EmptyObject obj2 = deserialize(NestedEdn, EmptyObject.class); assertFalse(obj1.equals(obj2)); binaryRoundTrip(obj1); binaryRoundTrip(obj2); } @Test public void unknownFieldsAreSerialized() { EmptyObject nestedObj = deserialize(TaggedEdn, EmptyObject.class);
String actualEdn = serialize(nestedObj);
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/ExtensibilityTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T fromFressianByteArray(byte[] bytes) { // return FressianSerialization.fromFressianByteArray(bytes); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static byte[] toFressianByteArray(Object o) { // return FressianSerialization.toFressianByteArray(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.fromFressianByteArray; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.DynamicObject.toFressianByteArray; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.List; import java.util.Map; import org.fressian.Reader; import org.fressian.Writer; import org.fressian.handlers.ReadHandler; import org.fressian.handlers.WriteHandler; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class ExtensibilityTest { private static final String Edn = "#dh{:dumb [#MyDumbClass{:version 1, :str \"str\"}]}"; @BeforeEach public void setup() { DynamicObject.registerType(DumbClass.class, new DumbClassTranslator()); DynamicObject.registerTag(DumbClassHolder.class, "dh"); DynamicObject.registerType(DumbClass.class, "dumb", new DumbClassReader(), new DumbClassWriter()); } @AfterEach public void teardown() { DynamicObject.deregisterType(DumbClass.class); DynamicObject.deregisterTag(DumbClassHolder.class); } @Test public void roundTrip() {
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T fromFressianByteArray(byte[] bytes) { // return FressianSerialization.fromFressianByteArray(bytes); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static byte[] toFressianByteArray(Object o) { // return FressianSerialization.toFressianByteArray(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/ExtensibilityTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.fromFressianByteArray; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.DynamicObject.toFressianByteArray; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.List; import java.util.Map; import org.fressian.Reader; import org.fressian.Writer; import org.fressian.handlers.ReadHandler; import org.fressian.handlers.WriteHandler; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class ExtensibilityTest { private static final String Edn = "#dh{:dumb [#MyDumbClass{:version 1, :str \"str\"}]}"; @BeforeEach public void setup() { DynamicObject.registerType(DumbClass.class, new DumbClassTranslator()); DynamicObject.registerTag(DumbClassHolder.class, "dh"); DynamicObject.registerType(DumbClass.class, "dumb", new DumbClassReader(), new DumbClassWriter()); } @AfterEach public void teardown() { DynamicObject.deregisterType(DumbClass.class); DynamicObject.deregisterTag(DumbClassHolder.class); } @Test public void roundTrip() {
DumbClassHolder holder = deserialize(Edn, DumbClassHolder.class);
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/ExtensibilityTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T fromFressianByteArray(byte[] bytes) { // return FressianSerialization.fromFressianByteArray(bytes); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static byte[] toFressianByteArray(Object o) { // return FressianSerialization.toFressianByteArray(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.fromFressianByteArray; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.DynamicObject.toFressianByteArray; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.List; import java.util.Map; import org.fressian.Reader; import org.fressian.Writer; import org.fressian.handlers.ReadHandler; import org.fressian.handlers.WriteHandler; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class ExtensibilityTest { private static final String Edn = "#dh{:dumb [#MyDumbClass{:version 1, :str \"str\"}]}"; @BeforeEach public void setup() { DynamicObject.registerType(DumbClass.class, new DumbClassTranslator()); DynamicObject.registerTag(DumbClassHolder.class, "dh"); DynamicObject.registerType(DumbClass.class, "dumb", new DumbClassReader(), new DumbClassWriter()); } @AfterEach public void teardown() { DynamicObject.deregisterType(DumbClass.class); DynamicObject.deregisterTag(DumbClassHolder.class); } @Test public void roundTrip() { DumbClassHolder holder = deserialize(Edn, DumbClassHolder.class);
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T fromFressianByteArray(byte[] bytes) { // return FressianSerialization.fromFressianByteArray(bytes); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static byte[] toFressianByteArray(Object o) { // return FressianSerialization.toFressianByteArray(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/ExtensibilityTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.fromFressianByteArray; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.DynamicObject.toFressianByteArray; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.List; import java.util.Map; import org.fressian.Reader; import org.fressian.Writer; import org.fressian.handlers.ReadHandler; import org.fressian.handlers.WriteHandler; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class ExtensibilityTest { private static final String Edn = "#dh{:dumb [#MyDumbClass{:version 1, :str \"str\"}]}"; @BeforeEach public void setup() { DynamicObject.registerType(DumbClass.class, new DumbClassTranslator()); DynamicObject.registerTag(DumbClassHolder.class, "dh"); DynamicObject.registerType(DumbClass.class, "dumb", new DumbClassReader(), new DumbClassWriter()); } @AfterEach public void teardown() { DynamicObject.deregisterType(DumbClass.class); DynamicObject.deregisterTag(DumbClassHolder.class); } @Test public void roundTrip() { DumbClassHolder holder = deserialize(Edn, DumbClassHolder.class);
String serialized = serialize(holder);
rschmitt/dynamic-object
src/test/java/com/github/rschmitt/dynamicobject/ExtensibilityTest.java
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T fromFressianByteArray(byte[] bytes) { // return FressianSerialization.fromFressianByteArray(bytes); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static byte[] toFressianByteArray(Object o) { // return FressianSerialization.toFressianByteArray(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // }
import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.fromFressianByteArray; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.DynamicObject.toFressianByteArray; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.List; import java.util.Map; import org.fressian.Reader; import org.fressian.Writer; import org.fressian.handlers.ReadHandler; import org.fressian.handlers.WriteHandler; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;
package com.github.rschmitt.dynamicobject; public class ExtensibilityTest { private static final String Edn = "#dh{:dumb [#MyDumbClass{:version 1, :str \"str\"}]}"; @BeforeEach public void setup() { DynamicObject.registerType(DumbClass.class, new DumbClassTranslator()); DynamicObject.registerTag(DumbClassHolder.class, "dh"); DynamicObject.registerType(DumbClass.class, "dumb", new DumbClassReader(), new DumbClassWriter()); } @AfterEach public void teardown() { DynamicObject.deregisterType(DumbClass.class); DynamicObject.deregisterTag(DumbClassHolder.class); } @Test public void roundTrip() { DumbClassHolder holder = deserialize(Edn, DumbClassHolder.class); String serialized = serialize(holder);
// Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T deserialize(String edn, Class<T> type) { // return EdnSerialization.deserialize(edn, type); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static <T> T fromFressianByteArray(byte[] bytes) { // return FressianSerialization.fromFressianByteArray(bytes); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static String serialize(Object o) { // return EdnSerialization.serialize(o); // } // // Path: src/main/java/com/github/rschmitt/dynamicobject/DynamicObject.java // static byte[] toFressianByteArray(Object o) { // return FressianSerialization.toFressianByteArray(o); // } // // Path: src/test/java/com/github/rschmitt/dynamicobject/TestUtils.java // public static void assertEquivalent(String expected, String actual) { // assertEquals(genericRead(expected), genericRead(actual)); // } // Path: src/test/java/com/github/rschmitt/dynamicobject/ExtensibilityTest.java import static com.github.rschmitt.dynamicobject.DynamicObject.deserialize; import static com.github.rschmitt.dynamicobject.DynamicObject.fromFressianByteArray; import static com.github.rschmitt.dynamicobject.DynamicObject.serialize; import static com.github.rschmitt.dynamicobject.DynamicObject.toFressianByteArray; import static com.github.rschmitt.dynamicobject.TestUtils.assertEquivalent; import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.List; import java.util.Map; import org.fressian.Reader; import org.fressian.Writer; import org.fressian.handlers.ReadHandler; import org.fressian.handlers.WriteHandler; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; package com.github.rschmitt.dynamicobject; public class ExtensibilityTest { private static final String Edn = "#dh{:dumb [#MyDumbClass{:version 1, :str \"str\"}]}"; @BeforeEach public void setup() { DynamicObject.registerType(DumbClass.class, new DumbClassTranslator()); DynamicObject.registerTag(DumbClassHolder.class, "dh"); DynamicObject.registerType(DumbClass.class, "dumb", new DumbClassReader(), new DumbClassWriter()); } @AfterEach public void teardown() { DynamicObject.deregisterType(DumbClass.class); DynamicObject.deregisterTag(DumbClassHolder.class); } @Test public void roundTrip() { DumbClassHolder holder = deserialize(Edn, DumbClassHolder.class); String serialized = serialize(holder);
assertEquivalent(Edn, serialized);