diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..837d975fa --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +spaces_around_operators = true diff --git a/pom.xml b/pom.xml index 485139656..273173ad5 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.avaje.ebean ebean - 9.1.1-SNAPSHOT + 9.2.2-SNAPSHOT jar ebean @@ -20,7 +20,7 @@ - scm:git:https://github.com/ebean-orm/ebean.git + scm:git:git@github.com:ebean-orm/ebean.git HEAD diff --git a/src/main/java/com/avaje/ebean/BackgroundExecutor.java b/src/main/java/com/avaje/ebean/BackgroundExecutor.java index 12edb0a51..8f2afbf64 100644 --- a/src/main/java/com/avaje/ebean/BackgroundExecutor.java +++ b/src/main/java/com/avaje/ebean/BackgroundExecutor.java @@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit; * code if you want. It can be useful for some server caching implementations * (background population and trimming of the cache etc). *

- * + * * @author rbygrave */ public interface BackgroundExecutor { diff --git a/src/main/java/com/avaje/ebean/BeanState.java b/src/main/java/com/avaje/ebean/BeanState.java index a6708a783..7972abbd4 100644 --- a/src/main/java/com/avaje/ebean/BeanState.java +++ b/src/main/java/com/avaje/ebean/BeanState.java @@ -45,13 +45,11 @@ public interface BeanState { /** * Set the loaded state of the property given it's name. - * *

- * Typically this would be used to set the loaded state of a property - * to false to ensure that the specific property is excluded from a - * stateless update. + * Typically this would be used to set the loaded state of a property + * to false to ensure that the specific property is excluded from a + * stateless update. *

- * *
{@code
    *
    *   // populate a bean via say JSON
@@ -64,8 +62,7 @@ public interface BeanState {
    *   user.update();
    *
    * }
- * - * + *

* This will throw an IllegalArgumentException if the property is unknown. */ void setPropertyLoaded(String propertyName, boolean loaded); @@ -87,8 +84,8 @@ public interface BeanState { /** * Return a map of the updated properties and their new and old values. */ - Map getDirtyValues(); - + Map getDirtyValues(); + /** * Return true if the bean is readOnly. *

@@ -125,4 +122,4 @@ public interface BeanState { * Reset the bean putting it into NEW state such that a save() results in an insert. */ void resetForInsert(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/CallableSql.java b/src/main/java/com/avaje/ebean/CallableSql.java index fcff6b43b..edeb670a0 100644 --- a/src/main/java/com/avaje/ebean/CallableSql.java +++ b/src/main/java/com/avaje/ebean/CallableSql.java @@ -13,65 +13,66 @@ import java.sql.SQLException; *

* Example 1: *

- * - *
- * String sql = "{call sp_order_mod(?,?)}";
- * 
+ * 
{@code
+ *
+ * String sql = "{call sp_order_mod(?,?)}";
+ *
  * CallableSql cs = Ebean.createCallableSql(sql);
- * cs.setParameter(1, "turbo");
+ * cs.setParameter(1, "turbo");
  * cs.registerOut(2, Types.INTEGER);
- * 
+ *
  * Ebean.execute(cs);
- * 
+ *
  * // read the out parameter
  * Integer returnValue = (Integer) cs.getObject(2);
- * 
- * + * + * }
*

* Example 2:
* Includes batch mode, table modification information and label. Note that the * label is really only to help people reading the transaction logs to identify * the procedure called etc. *

- * - *
- * String sql = "{call sp_insert_order(?,?)}";
- * 
+ *
+ * 
{@code
+ *
+ * String sql = "{call sp_insert_order(?,?)}";
+ *
  * CallableSql cs = Ebean.createCallableSql(sql);
- * 
+ *
  * // Inform Ebean this stored procedure inserts into the
  * // oe_order table and inserts + updates the oe_order_detail table.
  * // this is used to invalidate objects in the cache
- * cs.addModification("oe_order", true, false, false);
- * cs.addModification("oe_order_detail", true, true, false);
- * 
+ * cs.addModification("oe_order", true, false, false);
+ * cs.addModification("oe_order_detail", true, true, false);
+ *
  * Transaction t = Ebean.startTransaction();
- * 
+ *
  * // execute using JDBC batching 10 statements at a time
  * t.setBatchMode(true);
  * t.setBatchSize(10);
  * try {
- *   cs.setParameter(1, "Was");
- *   cs.setParameter(2, "Banana");
+ *   cs.setParameter(1, "Was");
+ *   cs.setParameter(2, "Banana");
  *   Ebean.execute(cs);
- * 
- *   cs.setParameter(1, "Here");
- *   cs.setParameter(2, "Kumera");
+ *
+ *   cs.setParameter(1, "Here");
+ *   cs.setParameter(2, "Kumera");
  *   Ebean.execute(cs);
- * 
- *   cs.setParameter(1, "More");
- *   cs.setParameter(2, "Apple");
+ *
+ *   cs.setParameter(1, "More");
+ *   cs.setParameter(2, "Apple");
  *   Ebean.execute(cs);
- * 
- *   // Ebean.externalModification("oe_order",true,false,false);
- *   // Ebean.externalModification("oe_order_detail",true,true,false);
+ *
+ *   // Ebean.externalModification("oe_order",true,false,false);
+ *   // Ebean.externalModification("oe_order_detail",true,true,false);
  *   Ebean.commitTransaction();
- * 
+ *
  * } finally {
  *   Ebean.endTransaction();
  * }
- * 
- * + * }
+ * * @see com.avaje.ebean.SqlUpdate * @see com.avaje.ebean.Ebean#execute(CallableSql) */ @@ -119,21 +120,17 @@ public interface CallableSql { * This is designed so that you do not need to set params in index order. You * can set/register param 2 before param 1 etc. *

- * - * @param position - * the index position of the parameter. - * @param value - * the value of the parameter. + * + * @param position the index position of the parameter. + * @param value the value of the parameter. */ CallableSql bind(int position, Object value); /** * Bind a positioned parameter (same as bind method). - * - * @param position - * the index position of the parameter. - * @param value - * the value of the parameter. + * + * @param position the index position of the parameter. + * @param value the value of the parameter. */ CallableSql setParameter(int position, Object value); @@ -147,11 +144,9 @@ public interface CallableSql { * This is designed so that you do not need to register params in index order. * You can set/register param 2 before param 1 etc. *

- * - * @param position - * the index position of the parameter (starts with 1). - * @param type - * the jdbc type of the OUT parameter that will be read. + * + * @param position the index position of the parameter (starts with 1). + * @param type the jdbc type of the OUT parameter that will be read. */ CallableSql registerOut(int position, int type); @@ -168,7 +163,6 @@ public interface CallableSql { Object getObject(int position); /** - * * You can extend this object and override this method for more advanced * stored procedure calls. This would be the case when ResultSets are returned * etc. @@ -190,4 +184,4 @@ public interface CallableSql { */ CallableSql addModification(String tableName, boolean inserts, boolean updates, boolean deletes); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java index dab7d91ad..6cb9d14ce 100644 --- a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java +++ b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java @@ -1,10 +1,9 @@ package com.avaje.ebean; -import java.util.ArrayList; +import com.avaje.ebean.RawSql.ColumnMapping; import javax.persistence.PersistenceException; - -import com.avaje.ebean.RawSql.ColumnMapping; +import java.util.ArrayList; /** * Parses columnMapping (select clause) mapping columns to bean properties. @@ -30,7 +29,7 @@ final class DRawSqlColumnsParser { private ColumnMapping parse() { - ArrayList columns = new ArrayList(); + ArrayList columns = new ArrayList<>(); while (pos <= end) { ColumnMapping.Column c = nextColumnInfo(); columns.add(c); @@ -47,10 +46,10 @@ final class DRawSqlColumnsParser { String[] split = colInfo.split("\\s(?=[^\\)]*(?:\\(|$))"); if (split.length > 1) { - ArrayList tmp = new ArrayList(split.length); - for (int i = 0; i < split.length; i++) { - if (!split[i].trim().isEmpty()) { - tmp.add(split[i].trim()); + ArrayList tmp = new ArrayList<>(split.length); + for (String aSplit : split) { + if (!aSplit.trim().isEmpty()) { + tmp.add(aSplit.trim()); } } split = tmp.toArray(new String[tmp.size()]); @@ -66,15 +65,15 @@ final class DRawSqlColumnsParser { if (split.length == 2) { return new ColumnMapping.Column(indexPos++, split[0], split[1]); } - // Ok, we now expect/require the AS keyword and it should be the - // second to last word in the colInfo content + // Ok, we now expect/require the AS keyword and it should be the + // second to last word in the colInfo content if (!split[split.length - 2].equalsIgnoreCase("as")) { throw new PersistenceException("Expecting AS keyword as second to last word when parsing column " + colInfo); } // build back the 'column formula' that precedes the AS keyword StringBuilder sb = new StringBuilder(); sb.append(split[0]); - for (int i = 1; i < split.length-2; i++) { + for (int i = 1; i < split.length - 2; i++) { sb.append(" ").append(split[i]); } return new ColumnMapping.Column(indexPos++, sb.toString(), split[split.length - 1]); diff --git a/src/main/java/com/avaje/ebean/DRawSqlParser.java b/src/main/java/com/avaje/ebean/DRawSqlParser.java index 1f3b9a560..a212c795c 100644 --- a/src/main/java/com/avaje/ebean/DRawSqlParser.java +++ b/src/main/java/com/avaje/ebean/DRawSqlParser.java @@ -47,7 +47,7 @@ class DRawSqlParser { private DRawSqlParser(String sqlString) { sqlString = sqlString.trim(); - sqlString = sqlString.replace('\n',' '); + sqlString = sqlString.replace('\n', ' '); this.sql = sqlString; this.hasPlaceHolders = findAndRemovePlaceHolders(); this.textParser = new SimpleTextParser(sqlString); diff --git a/src/main/java/com/avaje/ebean/DocumentStore.java b/src/main/java/com/avaje/ebean/DocumentStore.java index 22b30f953..95e0a1134 100644 --- a/src/main/java/com/avaje/ebean/DocumentStore.java +++ b/src/main/java/com/avaje/ebean/DocumentStore.java @@ -93,7 +93,6 @@ public interface DocumentStore { *

* Typically this is called indirectly by findPagedList() on the query that has setUseDocStore(true). *

- * *
{@code
    *
    * PagedList newCustomers =
@@ -104,7 +103,6 @@ public interface DocumentStore {
    *    .findPagedList();
    *
    * }
- * */ PagedList findPagedList(DocQueryRequest request); @@ -117,7 +115,6 @@ public interface DocumentStore { *

* Typically this is called indirectly by findEach() on the query that has setUseDocStore(true). *

- * *
{@code
    *
    *  server.find(Order.class)
@@ -146,8 +143,6 @@ public interface DocumentStore {
    * 

* Typically this is called indirectly by findEachWhile() on the query that has setUseDocStore(true). *

- * - * *
{@code
    *
    *  server.find(Order.class)
@@ -175,7 +170,6 @@ public interface DocumentStore {
 
   /**
    * Drop the index from the document store (similar to DDL drop table).
-   *
    * 
{@code
    *
    *   DocumentStore documentStore = server.docStore();
@@ -183,13 +177,11 @@ public interface DocumentStore {
    *   documentStore.dropIndex("product_copy");
    *
    * }
- * */ void dropIndex(String indexName); /** * Create an index given a mapping file as a resource in the classPath (similar to DDL create table). - * *
{@code
    *
    *   DocumentStore documentStore = server.docStore();
@@ -201,8 +193,8 @@ public interface DocumentStore {
    *
    * }
* - * @param indexName the name of the new index - * @param alias the alias of the index + * @param indexName the name of the new index + * @param alias the alias of the index */ void createIndex(String indexName, String alias); @@ -222,7 +214,6 @@ public interface DocumentStore { * documentStore.indexSettings("product", settings); * * }
- * *
{@code
    *
    *   // refresh_interval 1s ... restore after bulk loading
@@ -244,7 +235,6 @@ public interface DocumentStore {
    * 

* This copy process does not use the database but instead will copy from the source index to a destination index. *

- * *
{@code
    *
    *  long copyCount = documentStore.copyIndex(Product.class, "product_copy");
@@ -263,7 +253,6 @@ public interface DocumentStore {
    * 

* To support this the document needs to have a @WhenModified property. *

- * *
{@code
    *
    *  long copyCount = documentStore.copyIndex(Product.class, "product_copy", sinceMillis);
@@ -279,7 +268,6 @@ public interface DocumentStore {
   /**
    * Copy from a source index to a new index taking only the documents
    * matching the given query.
-   *
    * 
{@code
    *
    *  // predicates to select the source documents to copy
diff --git a/src/main/java/com/avaje/ebean/Ebean.java b/src/main/java/com/avaje/ebean/Ebean.java
index ffd330b1a..e7012913e 100644
--- a/src/main/java/com/avaje/ebean/Ebean.java
+++ b/src/main/java/com/avaje/ebean/Ebean.java
@@ -41,7 +41,6 @@ import java.util.concurrent.ConcurrentHashMap;
  * {@link #find(Class)} that proxy through to the 'default' EbeanServer. This
  * can be useful for applications that use a single database.
  * 
- * 
  * 

* For developer convenience Ebean has static methods that proxy through to the * methods on the 'default' EbeanServer. These methods are provided for @@ -59,7 +58,6 @@ import java.util.concurrent.ConcurrentHashMap; * created automatically they are configured using information in the * ebean.properties file. *

- * *
{@code
  *
  *   // fetch shipped orders (and also their customer)
@@ -76,40 +74,36 @@ import java.util.concurrent.ConcurrentHashMap;
  *   }
  *
  * }
- * *
{@code
  *
  *   // fetch order 10, modify and save
  *   Order order = Ebean.find(Order.class, 10);
- * 
+ *
  *   OrderStatus shipped = Ebean.getReference(OrderStatus.class,"SHIPPED");
  *   order.setStatus(shipped);
  *   order.setShippedDate(shippedDate);
  *   ...
- * 
+ *
  *   // implicitly creates a transaction and commits
  *   Ebean.save(order);
  *
  * }
- * *

* When you have multiple databases and need access to a specific one the * {@link #getServer(String)} method provides access to the EbeanServer for that * specific database. *

- * *
{@code
  *
  *   // Get access to the Human Resources EbeanServer/Database
  *   EbeanServer hrDb = Ebean.getServer("hr");
- * 
- * 
+ *
  *   // fetch contact 3 from the HR database
  *   Contact contact = hrDb.find(Contact.class, 3);
- * 
+ *
  *   contact.setName("I'm going to change");
  *   ...
- * 
+ *
  *   // save the contact back to the HR database
  *   hrDb.save(contact);
  *
@@ -132,13 +126,13 @@ public final class Ebean {
     /**
      * Cache for fast concurrent read access.
      */
-    private final ConcurrentHashMap concMap = new ConcurrentHashMap();
+    private final ConcurrentHashMap concMap = new ConcurrentHashMap<>();
 
     /**
      * Cache for synchronized read, creation and put. Protected by the monitor
      * object.
      */
-    private final HashMap syncMap = new HashMap();
+    private final HashMap syncMap = new HashMap<>();
 
     private final Object monitor = new Object();
 
@@ -217,7 +211,7 @@ public final class Ebean {
     private void register(EbeanServer server, boolean isDefaultServer) {
       registerWithName(server.getName(), server, isDefaultServer);
     }
-    
+
     private void registerWithName(String name, EbeanServer server, boolean isDefaultServer) {
       synchronized (monitor) {
         concMap.put(name, server);
@@ -242,16 +236,14 @@ public final class Ebean {
    * transactions and the ability to use transactions created externally to
    * Ebean.
    * 

- * *
{@code
    * // use the "hr" database
    * EbeanServer hrDatabase = Ebean.getServer("hr");
-   * 
+   *
    * Person person = hrDatabase.find(Person.class, 10);
    * }
- * - * @param name - * the name of the server, can use null for the 'default server' + * + * @param name the name of the server, can use null for the 'default server' */ public static EbeanServer getServer(String name) { return serverMgr.get(name); @@ -304,7 +296,7 @@ public final class Ebean { serverMgr.registerWithName(name, server, defaultServer); return originalPrimaryServer; } - + /** * Return the next identity value for a given bean type. *

@@ -336,7 +328,6 @@ public final class Ebean { * Example of using a transaction to span multiple calls to find(), save() * etc. *

- * *
{@code
    *
    *   // start a transaction (stored in a ThreadLocal)
@@ -345,9 +336,9 @@ public final class Ebean {
    * 	   Order order = Ebean.find(Order.class,10); ...
    *
    * 	   Ebean.save(order);
-   * 
+   *
    * 	   Ebean.commitTransaction();
-   * 
+   *
    *   } finally {
    * 	   // rollback if we didn't commit
    * 	   // i.e. an exception occurred before commitTransaction().
@@ -355,7 +346,6 @@ public final class Ebean {
    *   }
    *
    * }
- * *

* If you want to externalise the transaction management then you should be * able to do this via EbeanServer. Specifically with EbeanServer you can pass @@ -371,10 +361,8 @@ public final class Ebean { /** * Start a transaction additionally specifying the isolation level. - * - * @param isolation - * the Transaction isolation level - * + * + * @param isolation the Transaction isolation level */ public static Transaction beginTransaction(TxIsolation isolation) { return serverMgr.getDefaultServer().beginTransaction(isolation); @@ -382,12 +370,10 @@ public final class Ebean { /** * Start a transaction typically specifying REQUIRES_NEW or REQUIRED semantics. - * *

* Note that this provides an try finally alternative to using {@link #execute(TxScope, TxCallable)} or * {@link #execute(TxScope, TxRunnable)}. *

- * *

REQUIRES_NEW example:

*
{@code
    * // Start a new transaction. If there is a current transaction
@@ -408,7 +394,6 @@ public final class Ebean {
    * }
    *
    * }
- * *

REQUIRED example:

*
{@code
    *
@@ -431,7 +416,7 @@ public final class Ebean {
    *
    * }
*/ - public static Transaction beginTransaction(TxScope scope){ + public static Transaction beginTransaction(TxScope scope) { return serverMgr.getDefaultServer().beginTransaction(scope); } @@ -449,7 +434,6 @@ public final class Ebean { * If there is no currently active transaction then a PersistenceException is thrown. * * @param transactionCallback the transaction callback to be registered with the current transaction - * * @throws PersistenceException if there is no currently active transaction */ public static void register(TransactionCallback transactionCallback) throws PersistenceException { @@ -480,7 +464,6 @@ public final class Ebean { *

* Code example: *

- * *
{@code
    *   Ebean.beginTransaction();
    *   try {
@@ -488,7 +471,7 @@ public final class Ebean {
    *
    *     // commit at the end
    *     Ebean.commitTransaction();
-   * 
+   *
    *   } finally {
    *     // if commit didn't occur then rollback the transaction
    *     Ebean.endTransaction();
@@ -532,16 +515,14 @@ public final class Ebean {
    * In this example below the details property has a CascadeType.ALL set so
    * saving an order will also save all its details.
    * 

- * *
{@code
    *   public class Order { ...
-   * 	
+   *
    * 	   @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
    * 	   List details;
    * 	   ...
    *   }
    * }
- * *

* When a save cascades via a OneToMany or ManyToMany Ebean will automatically * set the 'parent' object to the 'detail' object. In the example below in @@ -576,16 +557,15 @@ public final class Ebean { *

* An unmodified bean that is saved or updated is normally skipped and this marks the bean as * dirty so that it is not skipped. - * *

{@code
-   * 
+   *
    *   Customer customer = Ebean.find(Customer, id);
-   * 
+   *
    *   // mark the bean as dirty so that a save() or update() will
    *   // increment the version property
    *   Ebean.markAsDirty(customer);
    *   Ebean.save(customer);
-   * 
+   *
    * }
*/ public static void markAsDirty(Object bean) throws OptimisticLockException { @@ -614,17 +594,16 @@ public final class Ebean { * controls if only the changed properties are included in the update or if all the loaded * properties are included instead. *

- * *
{@code
-   * 
+   *
    *   // A 'stateless update' example
    *   Customer customer = new Customer();
    *   customer.setId(7);
    *   customer.setName("ModifiedNameNoOCC");
    *   ebeanServer.update(customer);
-   * 
+   *
    * }
- * + * * @see ServerConfig#setUpdatesDeleteMissingChildren(boolean) * @see ServerConfig#setUpdateChangesOnly(boolean) */ @@ -731,7 +710,6 @@ public final class Ebean { /** * Refresh a 'many' property of a bean. - * *
{@code
    *
    *   Order order = ...;
@@ -740,11 +718,9 @@ public final class Ebean {
    *   Ebean.refreshMany(order, "details");
    *
    * }
- * - * @param bean - * the entity bean containing the List Set or Map to refresh. - * @param manyPropertyName - * the property name of the List Set or Map to refresh. + * + * @param bean the entity bean containing the List Set or Map to refresh. + * @param manyPropertyName the property name of the List Set or Map to refresh. */ public static void refreshMany(Object bean, String manyPropertyName) { serverMgr.getDefaultServer().refreshMany(bean, manyPropertyName); @@ -755,24 +731,21 @@ public final class Ebean { *

* This is sometimes described as a proxy (with lazy loading). *

- * *
{@code
    *
    *   Product product = Ebean.getReference(Product.class, 1);
-   * 
+   *
    *   // You can get the id without causing a fetch/lazy load
    *   Integer productId = product.getId();
-   * 
+   *
    *   // If you try to get any other property a fetch/lazy loading will occur
    *   // This will cause a query to execute...
    *   String name = product.getName();
    *
    * }
- * - * @param beanType - * the type of entity bean - * @param id - * the id value + * + * @param beanType the type of entity bean + * @param id the id value */ public static T getReference(Class beanType, Object id) { return serverMgr.getDefaultServer().getReference(beanType, id); @@ -796,29 +769,26 @@ public final class Ebean { * Note that the sorting uses a Comparator and Collections.sort(); and does * not invoke a DB query. *

- * *
{@code
-   * 
+   *
    *   // find orders and their customers
    *   List list = Ebean.find(Order.class)
    *     .fetch("customer")
    *     .orderBy("id")
    *     .findList();
-   * 
+   *
    *   // sort by customer name ascending, then by order shipDate
    *   // ... then by the order status descending
    *   Ebean.sort(list, "customer.name, shipDate, status desc");
-   * 
+   *
    *   // sort by customer name descending (with nulls low)
    *   // ... then by the order id
    *   Ebean.sort(list, "customer.name desc nullsLow, id");
-   * 
+   *
    * }
- * - * @param list - * the list of entity beans - * @param sortByClause - * the properties to sort the list by + * + * @param list the list of entity beans + * @param sortByClause the properties to sort the list by */ public static void sort(List list, String sortByClause) { serverMgr.getDefaultServer().sort(list, sortByClause); @@ -826,35 +796,35 @@ public final class Ebean { /** * Find a bean using its unique id. This will not use caching. - * *
{@code
+   *
    *   // Fetch order 1
    *   Order order = Ebean.find(Order.class, 1);
+   *
    * }
- * *

* If you want more control over the query then you can use createQuery() and * Query.findUnique(); *

- * *
{@code
+   *
    *   // ... additionally fetching customer, customer shipping address,
    *   // order details, and the product associated with each order detail.
    *   // note: only product id and name is fetch (its a "partial object").
    *   // note: all other objects use "*" and have all their properties fetched.
-   * 
+   *
    *   Query query = Ebean.find(Order.class)
    *     .setId(1)
    *     .fetch("customer")
    *     .fetch("customer.shippingAddress")
    *     .fetch("details")
    *     .query();
-   * 
+   *
    *   // fetch associated products but only fetch their product id and name
    *   query.fetch("details.product", "name");
-   * 
+   *
    *   // traverse the object graph...
-   * 
+   *
    *   Order order = query.findUnique();
    *   Customer customer = order.getCustomer();
    *   Address shippingAddress = customer.getShippingAddress();
@@ -864,11 +834,9 @@ public final class Ebean {
    *   String productName = product.getName();
    *
    * }
- * - * @param beanType - * the type of entity bean to fetch - * @param id - * the id value + * + * @param beanType the type of entity bean to fetch + * @param id the id value */ @Nullable public static T find(Class beanType, Object id) { @@ -903,7 +871,7 @@ public final class Ebean { /** * Create a CallableSql to execute a given stored procedure. - * + * * @see CallableSql */ public static CallableSql createCallableSql(String sql) { @@ -921,19 +889,18 @@ public final class Ebean { *

* An example: *

- * *
{@code
-   * 
+   *
    *   // The bean name and properties - "topic","postCount" and "id"
-   * 
+   *
    *   // will be converted into their associated table and column names
    *   String updStatement = "update topic set postCount = :pc where id = :id";
-   * 
+   *
    *   Update update = Ebean.createUpdate(Topic.class, updStatement);
-   * 
+   *
    *   update.set("pc", 9);
    *   update.set("id", 3);
-   * 
+   *
    *   int rows = update.execute();
    *   System.out.println("rows updated:" + rows);
    *
@@ -983,8 +950,7 @@ public final class Ebean {
    * which is was created.
    * 

* - * @param beanType - * the class of entity to be fetched + * @param beanType the class of entity to be fetched * @return A ORM Query object for this beanType */ public static Query createQuery(Class beanType) { @@ -996,12 +962,10 @@ public final class Ebean { * Parse the Ebean query language statement returning the query which can then * be modified (add expressions, change order by clause, change maxRows, change * fetch and select paths etc). - * + *

*

Example

- * *
{@code
    *
-   *
    *   // Find order additionally fetching the customer, details and details.product name.
    *
    *   String eql = "fetch customer fetch details fetch details.product (name) where id = :orderId ";
@@ -1023,9 +987,8 @@ public final class Ebean {
    * }
* * @param beanType The type of bean to fetch - * @param eql The Ebean query - * @param The type of the entity bean - * + * @param eql The Ebean query + * @param The type of the entity bean * @return The query with expressions defined as per the parsed query statement */ public static Query createQuery(Class beanType, String eql) { @@ -1040,9 +1003,8 @@ public final class Ebean { * exists is that people used to JPA will probably be looking for a * createQuery method (the same as entityManager). *

- * - * @param beanType - * the type of entity bean to find + * + * @param beanType the type of entity bean to find * @return A ORM Query object for this beanType */ public static Query find(Class beanType) { @@ -1103,28 +1065,24 @@ public final class Ebean { *

* Example: *

- * *
{@code
    *
    *   // example that uses 'named' parameters
    *   String s = "UPDATE f_topic set post_count = :count where id = :id"
-   * 
+   *
    *   SqlUpdate update = Ebean.createSqlUpdate(s);
-   * 
+   *
    *   update.setParameter("id", 1);
    *   update.setParameter("count", 50);
-   * 
+   *
    *   int modifiedCount = Ebean.execute(update);
-   * 
+   *
    *   String msg = "There where " + modifiedCount + "rows updated";
    *
    * }
- * - * @param sqlUpdate - * the update sql potentially with bind values - * + * + * @param sqlUpdate the update sql potentially with bind values * @return the number of rows updated or deleted. -1 if executed in batch. - * * @see SqlUpdate * @see CallableSql * @see Ebean#execute(CallableSql) @@ -1138,23 +1096,22 @@ public final class Ebean { *

* Example: *

- * *
{@code
    *
    *   String sql = "{call sp_order_modify(?,?,?)}";
-   * 
+   *
    *   CallableSql cs = Ebean.createCallableSql(sql);
    *   cs.setParameter(1, 27);
    *   cs.setParameter(2, "SHIPPED");
    *   cs.registerOut(3, Types.INTEGER);
-   * 
+   *
    *   Ebean.execute(cs);
-   * 
+   *
    *   // read the out parameter
    *   Integer returnValue = (Integer) cs.getObject(3);
    *
    * }
- * + * * @see CallableSql * @see Ebean#execute(SqlUpdate) */ @@ -1168,7 +1125,6 @@ public final class Ebean { * The scope can control the transaction type, isolation and rollback * semantics. *

- * *
{@code
    *
    *   // set specific transactional scope settings
@@ -1193,17 +1149,16 @@ public final class Ebean {
    * The default scope runs with REQUIRED and by default will rollback on any
    * exception (checked or runtime).
    * 

- * *
{@code
    *
    *   Ebean.execute(new TxRunnable() {
    *     public void run() {
    *       User u1 = Ebean.find(User.class, 1);
    *       User u2 = Ebean.find(User.class, 2);
-   * 
+   *
    *       u1.setName("u1 mod");
    *       u2.setName("u2 mod");
-   * 
+   *
    *       Ebean.save(u1);
    *       Ebean.save(u2);
    *     }
@@ -1221,7 +1176,6 @@ public final class Ebean {
    * The scope can control the transaction type, isolation and rollback
    * semantics.
    * 

- * *
{@code
    *
    *   // set specific transactional scope settings
@@ -1236,7 +1190,6 @@ public final class Ebean {
    *   });
    *
    * }
- * */ public static T execute(TxScope scope, TxCallable c) { return serverMgr.getDefaultServer().execute(scope, c); @@ -1252,20 +1205,19 @@ public final class Ebean { * This is basically the same as TxRunnable except that it returns an Object * (and you specify the return type via generics). *

- * *
{@code
    *
    *   Ebean.execute(new TxCallable() {
    *     public String call() {
    *       User u1 = Ebean.find(User.class, 1);
    *       User u2 = Ebean.find(User.class, 2);
-   * 
+   *
    *       u1.setName("u1 mod");
    *       u2.setName("u2 mod");
-   * 
+   *
    *       Ebean.save(u1);
    *       Ebean.save(u2);
-   * 
+   *
    *       return u1.getEmail();
    *     }
    *   });
@@ -1300,15 +1252,11 @@ public final class Ebean {
    * If there is NO current transaction when you call this method then this
    * information is registered immediately (with the transaction manager).
    * 

- * - * @param tableName - * the name of the table that was modified - * @param inserts - * true if rows where inserted into the table - * @param updates - * true if rows on the table where updated - * @param deletes - * true if rows on the table where deleted + * + * @param tableName the name of the table that was modified + * @param inserts true if rows where inserted into the table + * @param updates true if rows on the table where updated + * @param deletes true if rows on the table where deleted */ public static void externalModification(String tableName, boolean inserts, boolean updates, boolean deletes) { @@ -1327,7 +1275,6 @@ public final class Ebean { /** * Return the manager of the server cache ("L2" cache). - * */ public static ServerCacheManager getServerCacheManager() { return serverMgr.getDefaultServer().getServerCacheManager(); diff --git a/src/main/java/com/avaje/ebean/EbeanServer.java b/src/main/java/com/avaje/ebean/EbeanServer.java index a2bb1f4b4..269625ce5 100644 --- a/src/main/java/com/avaje/ebean/EbeanServer.java +++ b/src/main/java/com/avaje/ebean/EbeanServer.java @@ -169,7 +169,7 @@ public interface EbeanServer { *

* Useful if you use BeanPostConstructListeners or @PostConstruct Annotations. * In this case you should not use "new Bean...()". Making all bean construtors protected - * could be a good idea here. + * could be a good idea here. *

*/ T createEntityBean(Class type); @@ -224,9 +224,8 @@ public interface EbeanServer { * Parse the Ebean query language statement returning the query which can then * be modified (add expressions, change order by clause, change maxRows, change * fetch and select paths etc). - * + *

*

Example

- * *
{@code
    *
    *   // Find order additionally fetching the customer, details and details.product name.
@@ -250,9 +249,8 @@ public interface EbeanServer {
    * }
* * @param beanType The type of bean to fetch - * @param eql The Ebean query - * @param The type of the entity bean - * + * @param eql The Ebean query + * @param The type of the entity bean * @return The query with expressions defined as per the parsed query statement */ Query createQuery(Class beanType, String eql); @@ -752,7 +750,7 @@ public interface EbeanServer { * * @see Query#findIds() */ - List findIds(Query query, Transaction transaction); + List findIds(Query query, Transaction transaction); /** * Return a QueryIterator for the query. @@ -994,7 +992,7 @@ public interface EbeanServer { /** * Execute the query returning a list of values for a single property. - * + *

*

Example 1:

*
{@code
    *
@@ -1005,7 +1003,6 @@ public interface EbeanServer {
    *      .findSingleAttributeList();
    *
    * }
- * *

Example 2:

*
{@code
    *
@@ -1021,10 +1018,9 @@ public interface EbeanServer {
    * }
* * @return the list of values for the selected property - * * @see Query#findSingleAttributeList() */ -
List findSingleAttributeList(Query query, Transaction transaction); + List findSingleAttributeList(Query query, Transaction transaction); /** * Execute the query returning at most one entity bean or null (if no matching diff --git a/src/main/java/com/avaje/ebean/EbeanServerFactory.java b/src/main/java/com/avaje/ebean/EbeanServerFactory.java index d6326b5ea..bcc9a2062 100644 --- a/src/main/java/com/avaje/ebean/EbeanServerFactory.java +++ b/src/main/java/com/avaje/ebean/EbeanServerFactory.java @@ -36,7 +36,7 @@ public class EbeanServerFactory { /** * Initialise the container with clustering configuration. - * + *

* Call this prior to creating any EbeanServer instances or alternatively set the * ContainerConfig on the ServerConfig when creating the first EbeanServer instance. */ diff --git a/src/main/java/com/avaje/ebean/ExampleExpression.java b/src/main/java/com/avaje/ebean/ExampleExpression.java index e8fcf366a..6561ed76f 100644 --- a/src/main/java/com/avaje/ebean/ExampleExpression.java +++ b/src/main/java/com/avaje/ebean/ExampleExpression.java @@ -14,44 +14,44 @@ package com.avaje.ebean; * To get control over the options you can create an ExampleExpression and set * those options such as case insensitive etc. *

- * - *
+ *
+ * 
{@code
  * // create an example bean and set the properties
  * // with the query parameters you want
  * Customer example = new Customer();
- * example.setName("Rob%");
- * example.setNotes("%something%");
- * 
+ * example.setName("Rob%");
+ * example.setNotes("%something%");
+ *
  * List<Customer> list =
  *     Ebean.find(Customer.class)
  *         .where()
  *         // pass the bean into the where() clause
  *         .exampleLike(example)
  *         // you can add other expressions to the same query
- *         .gt("id", 2)
+ *         .gt("id", 2)
  *         .findList();
- * 
- * 
- * + * + * }
+ * * Similarly you can create an ExampleExpression - * - *
+ *
+ * 
{@code
+ *
  * Customer example = new Customer();
- * example.setName("Rob%");
- * example.setNotes("%something%");
- * 
+ * example.setName("Rob%");
+ * example.setNotes("%something%");
+ *
  * // create a ExampleExpression with more control
  * ExampleExpression qbe = new ExampleExpression(example, true, LikeType.EQUAL_TO)
  *     .includeZeros();
- * 
- * List<Customer> list =
+ *
+ * List list =
  *     Ebean.find(Customer.class)
  *         .where()
  *         .add(qbe)
  *         .findList();
- * 
- * - * @author Rob Bygrave + * + * }
*/ public interface ExampleExpression extends Expression { @@ -90,4 +90,4 @@ public interface ExampleExpression extends Expression { */ ExampleExpression useEqualTo(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/Expr.java b/src/main/java/com/avaje/ebean/Expr.java index a6a9e8b7c..41718174e 100644 --- a/src/main/java/com/avaje/ebean/Expr.java +++ b/src/main/java/com/avaje/ebean/Expr.java @@ -23,20 +23,19 @@ import java.util.Map; * Creates standard common expressions for using in a Query Where or Having * clause. *

- * - *
- *  // Example: Using an Expr.or() method
- * Query<Order> query = Ebean.createQuery(Order.class);
- * query.where( 
- * 		Expr.or(Expr.eq("status", Order.NEW),
- *     		    Expr.gt("orderDate", lastWeek));
- *     
- * List<Order> list = query.findList();
+ * 
{@code
+ *
+ * // Example: Using an Expr.or() method
+ * Query query = Ebean.createQuery(Order.class);
+ * query.where(
+ *     Expr.or(Expr.eq("status", Order.NEW),
+ *             Expr.gt("orderDate", lastWeek));
+ *
+ * List list = query.findList();
  * ...
- * 
- * + * }
+ * * @see Query#where() - * @author Rob Bygrave */ public class Expr { @@ -77,10 +76,10 @@ public class Expr { * Between - value between two given properties. */ public static Expression between(String lowProperty, String highProperty, Object value) { - + return Ebean.getExpressionFactory().betweenProperties(lowProperty, highProperty, value); } - + /** * Greater Than - property greater than the given value. */ @@ -142,8 +141,7 @@ public class Expr { /** * Create the query by Example expression specifying more options. */ - public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, - LikeType likeType) { + public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) { return Ebean.getExpressionFactory().exampleLike(example, caseInsensitive, likeType); } @@ -257,9 +255,8 @@ public class Expr { * Expression where all the property names in the map are equal to the * corresponding value. *

- * - * @param propertyMap - * a map keyed by property names. + * + * @param propertyMap a map keyed by property names. */ public static Expression allEq(Map propertyMap) { return Ebean.getExpressionFactory().allEq(propertyMap); diff --git a/src/main/java/com/avaje/ebean/ExpressionFactory.java b/src/main/java/com/avaje/ebean/ExpressionFactory.java index 2fb89e9b2..afa89b7b8 100644 --- a/src/main/java/com/avaje/ebean/ExpressionFactory.java +++ b/src/main/java/com/avaje/ebean/ExpressionFactory.java @@ -24,20 +24,19 @@ import java.util.Map; *

* The ExpressionList is returned from {@link Query#where()}. *

- * - *
- *  // Example: fetch orders where status equals new or orderDate > lastWeek.
- *  
- * Expression newOrLastWeek = 
- *   Expr.or(Expr.eq("status", Order.Status.NEW), 
- *           Expr.gt("orderDate", lastWeek));
- * 
- * Query<Order> query = Ebean.createQuery(Order.class);
+ * 
{@code
+ * // Example: fetch orders where status equals new or orderDate > lastWeek.
+ *
+ * Expression newOrLastWeek =
+ *     Expr.or(Expr.eq("status", Order.Status.NEW),
+ *             Expr.gt("orderDate", lastWeek));
+ *
+ * Query query = Ebean.createQuery(Order.class);
  * query.where().add(newOrLastWeek);
- * List<Order> list = query.findList();
+ * List list = query.findList();
  * ...
- * 
- * + * }
+ * * @see Query#where() */ public interface ExpressionFactory { @@ -282,7 +281,7 @@ public interface ExpressionFactory { * Exists expression */ Expression exists(Query subQuery); - + /** * Not exists expression */ @@ -319,9 +318,8 @@ public interface ExpressionFactory { * Expression where all the property names in the map are equal to the * corresponding value. *

- * - * @param propertyMap - * a map keyed by property names. + * + * @param propertyMap a map keyed by property names. */ Expression allEq(Map propertyMap); diff --git a/src/main/java/com/avaje/ebean/ExpressionList.java b/src/main/java/com/avaje/ebean/ExpressionList.java index 1d123899c..4164d5d2e 100644 --- a/src/main/java/com/avaje/ebean/ExpressionList.java +++ b/src/main/java/com/avaje/ebean/ExpressionList.java @@ -104,7 +104,7 @@ public interface ExpressionList { * Perform an 'As of' query using history tables to return the object graph * as of a time in the past. *

- * To perform this query the DB must have underlying history tables. + * To perform this query the DB must have underlying history tables. *

* * @param asOf the date time in the past at which you want to view the data @@ -201,7 +201,7 @@ public interface ExpressionList { /** * Execute the query returning a list of values for a single property. - * + *

*

Example 1:

*
{@code
    *
@@ -212,7 +212,7 @@ public interface ExpressionList {
    *      .findSingleAttributeList();
    *
    * }
- * + *

*

Example 2:

*
{@code
    *
@@ -240,7 +240,6 @@ public interface ExpressionList {
    * 

* * @throws NonUniqueResultException if more than one result was found - * * @see Query#findUnique() */ @Nullable @@ -292,7 +291,7 @@ public interface ExpressionList { * If maxRows is not set on the query prior to calling findPagedList() then a * PersistenceException is thrown. *

- * + *

*

{@code
    *
    *  PagedList pagedList = Ebean.find(Order.class)
@@ -309,7 +308,6 @@ public interface ExpressionList {
    * }
* * @return The PagedList - * * @see Query#findPagedList() */ PagedList findPagedList(); @@ -317,8 +315,8 @@ public interface ExpressionList { /** * Return versions of a @History entity bean. *

- * Generally this query is expected to be a find by id or unique predicates query. - * It will execute the query against the history returning the versions of the bean. + * Generally this query is expected to be a find by id or unique predicates query. + * It will execute the query against the history returning the versions of the bean. *

*/ List> findVersions(); @@ -326,8 +324,8 @@ public interface ExpressionList { /** * Return versions of a @History entity bean between the 2 timestamps. *

- * Generally this query is expected to be a find by id or unique predicates query. - * It will execute the query against the history returning the versions of the bean. + * Generally this query is expected to be a find by id or unique predicates query. + * It will execute the query against the history returning the versions of the bean. *

*/ List> findVersionsBetween(Timestamp start, Timestamp end); @@ -440,7 +438,6 @@ public interface ExpressionList { /** * Path exists - for the given path in a JSON document. - * *
{@code
    *
    *   where().jsonExists("content", "path.other")
@@ -448,13 +445,12 @@ public interface ExpressionList {
    * }
* * @param propertyName the property that holds a JSON document - * @param path the nested path in the JSON document in dot notation + * @param path the nested path in the JSON document in dot notation */ ExpressionList jsonExists(String propertyName, String path); /** * Path does not exist - for the given path in a JSON document. - * *
{@code
    *
    *   where().jsonNotExists("content", "path.other")
@@ -462,13 +458,13 @@ public interface ExpressionList {
    * }
* * @param propertyName the property that holds a JSON document - * @param path the nested path in the JSON document in dot notation + * @param path the nested path in the JSON document in dot notation */ ExpressionList jsonNotExists(String propertyName, String path); /** * Equal to expression for the value at the given path in the JSON document. - * + *

*

{@code
    *
    *   where().jsonEqualTo("content", "path.other", 34)
@@ -476,14 +472,14 @@ public interface ExpressionList {
    * }
* * @param propertyName the property that holds a JSON document - * @param path the nested path in the JSON document in dot notation - * @param value the value used to test against the document path's value + * @param path the nested path in the JSON document in dot notation + * @param value the value used to test against the document path's value */ ExpressionList jsonEqualTo(String propertyName, String path, Object value); /** * Not Equal to - for the given path in a JSON document. - * + *

*

{@code
    *
    *   where().jsonNotEqualTo("content", "path.other", 34)
@@ -491,14 +487,14 @@ public interface ExpressionList {
    * }
* * @param propertyName the property that holds a JSON document - * @param path the nested path in the JSON document in dot notation - * @param value the value used to test against the document path's value + * @param path the nested path in the JSON document in dot notation + * @param value the value used to test against the document path's value */ ExpressionList jsonNotEqualTo(String propertyName, String path, Object value); /** * Greater than - for the given path in a JSON document. - * + *

*

{@code
    *
    *   where().jsonGreaterThan("content", "path.other", 34)
@@ -509,7 +505,7 @@ public interface ExpressionList {
 
   /**
    * Greater than or equal to - for the given path in a JSON document.
-   *
+   * 

*

{@code
    *
    *   where().jsonGreaterOrEqual("content", "path.other", 34)
@@ -520,7 +516,7 @@ public interface ExpressionList {
 
   /**
    * Less than - for the given path in a JSON document.
-   *
+   * 

*

{@code
    *
    *   where().jsonLessThan("content", "path.other", 34)
@@ -531,7 +527,7 @@ public interface ExpressionList {
 
   /**
    * Less than or equal to - for the given path in a JSON document.
-   *
+   * 

*

{@code
    *
    *   where().jsonLessOrEqualTo("content", "path.other", 34)
@@ -542,7 +538,7 @@ public interface ExpressionList {
 
   /**
    * Between - for the given path in a JSON document.
-   *
+   * 

*

{@code
    *
    *   where().jsonBetween("content", "orderDate", lowerDateTime, upperDateTime)
@@ -556,7 +552,7 @@ public interface ExpressionList {
    * 

* This returns the list so that add() can be chained. *

- * + *

*

{@code
    *
    * Query query = Ebean.find(Customer.class);
@@ -647,7 +643,7 @@ public interface ExpressionList {
    * To get control over the options you can create an ExampleExpression and set
    * those options such as case insensitive etc.
    * 

- * + *

*

{@code
    *
    * // create an example bean and set the properties
@@ -663,9 +659,9 @@ public interface ExpressionList {
    *     .gt("id", 2).findList();
    *
    * }
- * + *

* Similarly you can create an ExampleExpression - * + *

*

{@code
    *
    * Customer example = new Customer();
@@ -804,8 +800,7 @@ public interface ExpressionList {
    * corresponding value.
    * 

* - * @param propertyMap - * a map keyed by property names. + * @param propertyMap a map keyed by property names. */ ExpressionList allEq(Map propertyMap); @@ -849,7 +844,7 @@ public interface ExpressionList { * then they are not translated. logical property name names (not fully * qualified) will still be translated to their physical name. *

- * + *

*

Example:

*
{@code
    *
@@ -881,7 +876,7 @@ public interface ExpressionList {
    * then they are not translated. logical property name names (not fully
    * qualified) will still be translated to their physical name.
    * 

- * + *

*

{@code
    *
    *   raw("orderQty < shipQty")
@@ -894,7 +889,7 @@ public interface ExpressionList {
    * Add a match expression.
    *
    * @param propertyName The property name for the match
-   * @param search The search value
+   * @param search       The search value
    */
   ExpressionList match(String propertyName, String search);
 
@@ -902,14 +897,14 @@ public interface ExpressionList {
    * Add a match expression with options.
    *
    * @param propertyName The property name for the match
-   * @param search The search value
+   * @param search       The search value
    */
   ExpressionList match(String propertyName, String search, Match options);
 
   /**
    * Add a multi-match expression.
    */
-  ExpressionList  multiMatch(String search, String... properties);
+  ExpressionList multiMatch(String search, String... properties);
 
   /**
    * Add a multi-match expression using options.
@@ -960,7 +955,7 @@ public interface ExpressionList {
    * typically you only explicitly need to use the and() junction
    * when it is nested inside an or() or not() junction.
    * 

- * + *

*

{@code
    *
    *  // Example: Nested and()
@@ -985,11 +980,11 @@ public interface ExpressionList {
   /**
    * Return a list of expressions that will be joined by OR's.
    * This is exactly the same as disjunction();
-   *
    * 

- * Use endOr() or endJunction() to end the OR junction. + *

+ * Use endOr() or endJunction() to end the OR junction. *

- * + *

*

{@code
    *
    *  // Example: Use or() to join
@@ -1016,10 +1011,10 @@ public interface ExpressionList {
   /**
    * Return a list of expressions that will be wrapped by NOT.
    * 

- * Use endNot() or endJunction() to end expressions being added to the - * NOT expression list. + * Use endNot() or endJunction() to end expressions being added to the + * NOT expression list. *

- * + *

*

@{code
    *
    *    .where()
@@ -1029,7 +1024,7 @@ public interface ExpressionList {
    *        .endNot()
    *
    * }
- * + *

*

@{code
    *
    * // Example: nested not()
diff --git a/src/main/java/com/avaje/ebean/FetchConfig.java b/src/main/java/com/avaje/ebean/FetchConfig.java
index fc4f3de11..fad86a69c 100644
--- a/src/main/java/com/avaje/ebean/FetchConfig.java
+++ b/src/main/java/com/avaje/ebean/FetchConfig.java
@@ -21,47 +21,52 @@ import java.io.Serializable;
  * is high (a lot of "Many" beans per "One" bean) then this can be more
  * efficient loaded as 2 SQL queries.
  * 

- * + *

*

{@code
  * // Normal fetch join results in a single SQL query
  * List list = Ebean.find(Order.class).fetch("details").findList();
- * 
+ *
  * // Find Orders join details using a single SQL query
  * }
*

* Example: Using a "query join" instead of a "fetch join" we instead use 2 SQL queries *

- * + *

*

{@code
+ *
  * // This will use 2 SQL queries to build this object graph
  * List list =
  *     Ebean.find(Order.class)
  *         .fetch("details", new FetchConfig().query())
  *         .findList();
- * 
+ *
  * // query 1) find order
  * // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
+ *
  * }
*

* Example: Using 2 "query joins" *

- * + *

*

{@code
+ *
  * // This will use 3 SQL queries to build this object graph
  * List list =
  *     Ebean.find(Order.class)
  *         .fetch("details", new FetchConfig().query())
  *         .fetch("customer", new FetchConfig().queryFirst(5))
  *         .findList();
- * 
+ *
  * // query 1) find order
  * // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
  * // query 3) find customer where id in (?,?,?,?,?) // first 5 customers
+ *
  * }
*

* Example: Using "query joins" and partial objects *

- * + *

+ * *

{@code
  * // This will use 3 SQL queries to build this object graph
  * List list =
@@ -73,13 +78,13 @@ import java.io.Serializable;
  *         .fetch("customer.contacts")
  *         .fetch("customer.shippingAddress")
  *         .findList();
- * 
+ *
  * // query 1) find order (status, shipDate)
  * // query 2) find orderDetail (quantity, price) fetch product (sku, name) where
  * // order.id in (?,? ...)
  * // query 3) find customer (name) fetch contacts (*) fetch shippingAddress (*)
  * // where id in (?,?,?,?,?)
- * 
+ *
  * // Note: the fetch of "details.product" is automatically included into the
  * // fetch of "details"
  * //
@@ -91,20 +96,21 @@ import java.io.Serializable;
  * immediately and the lazy defines the batch size to use for further lazy
  * loading (if lazy loading is invoked).
  * 

- * + *

*

{@code
+ *
  * List list =
  *     Ebean.find(Order.class)
  *         .fetch("customer", new FetchConfig().query(10).lazy(5))
  *         .findList();
- * 
+ *
  * // query 1) find order
  * // query 2) find customer where id in (?,?,?,?,?,?,?,?,?,?) // first 10 customers
  * // .. then if lazy loading of customers is invoked
  * // .. use a batch size of 5 to load the customers
- * 
+ *
  * }
- * + *

*

* Example of controlling the lazy loading query: *

@@ -112,22 +118,23 @@ import java.io.Serializable; * This gives us the ability to optimise the lazy loading query for a given use * case. *

- * + *

*

{@code
+ *
  * List list = Ebean.find(Order.class)
  *   .fetch("customer","name", new FetchConfig().lazy(5))
  *   .fetch("customer.contacts","contactName, phone, email")
  *   .fetch("customer.shippingAddress")
  *   .where().eq("status",Order.Status.NEW)
  *   .findList();
- * 
+ *
  * // query 1) find order where status = Order.Status.NEW
- * //  
- * // .. if lazy loading of customers is invoked 
+ * //
+ * // .. if lazy loading of customers is invoked
  * // .. use a batch size of 5 to load the customers
- * 
+ *
  * }
- * + * * @author mario * @author rbygrave */ @@ -159,9 +166,8 @@ public class FetchConfig implements Serializable { /** * Specify that this path should be lazy loaded with a specified batch size. - * - * @param lazyBatchSize - * the batch size for lazy loading + * + * @param lazyBatchSize the batch size for lazy loading */ public FetchConfig lazy(int lazyBatchSize) { this.lazyBatchSize = lazyBatchSize; @@ -193,9 +199,8 @@ public class FetchConfig implements Serializable { * This will load all beans on this path eagerly unless a {@link #lazy(int)} * is also used. *

- * - * @param queryBatchSize - * the batch size used to load beans on this path + * + * @param queryBatchSize the batch size used to load beans on this path */ public FetchConfig query(int queryBatchSize) { this.queryBatchSize = queryBatchSize; @@ -211,9 +216,8 @@ public class FetchConfig implements Serializable { * If there are more parent beans than the batch size then they will not be * loaded eagerly but instead use lazy loading. *

- * - * @param queryBatchSize - * the number of parent beans this path is populated for + * + * @param queryBatchSize the number of parent beans this path is populated for */ public FetchConfig queryFirst(int queryBatchSize) { this.queryBatchSize = queryBatchSize; @@ -227,7 +231,7 @@ public class FetchConfig implements Serializable { public int getLazyBatchSize() { return lazyBatchSize; } - + /** * Return the batch size for separate query load. */ diff --git a/src/main/java/com/avaje/ebean/Filter.java b/src/main/java/com/avaje/ebean/Filter.java index f5055123c..f8e1aab16 100644 --- a/src/main/java/com/avaje/ebean/Filter.java +++ b/src/main/java/com/avaje/ebean/Filter.java @@ -19,64 +19,63 @@ import java.util.Set; * The result of the filter method will leave the original list unmodified and * return a new List instance. *

- * - *
- * 
+ * 

+ *

{@code
+ *
  * // get a list of entities (query execution statistics in this case)
- * 
- * List<MetaQueryStatistic> list =
+ *
+ * List list =
  *     Ebean.find(MetaQueryStatistic.class).findList();
- * 
+ *
  * long nowMinus24Hrs = System.currentTimeMillis() - 24 * (1000 * 60 * 60);
- * 
+ *
  * // sort and filter the list returning a filtered list...
- * 
- * List<MetaQueryStatistic> filteredList =
+ *
+ * List filteredList =
  *     Ebean.filter(MetaQueryStatistic.class)
- *         .sort("avgTimeMicros desc")
- *         .gt("executionCount", 0)
- *         .gt("lastQueryTime", nowMinus24Hrs)
- *         .eq("autoTuned", true)
+ *         .sort("avgTimeMicros desc")
+ *         .gt("executionCount", 0)
+ *         .gt("lastQueryTime", nowMinus24Hrs)
+ *         .eq("autoTuned", true)
  *         .maxRows(10)
  *         .filter(list);
- * 
- * 
+ * + * }
*

* The propertyNames can traverse the object graph (e.g. customer.name) by using * dot notation. If any point during the object graph traversal to get a * property value is null then null is returned. *

- * - *
- * // examples of property names that 
+ * 

+ *

{@code
+ *
+ * // examples of property names that
  * // ... will traverse the object graph
  * // ... where customer is a property of our bean
- * 
+ *
  * customer.name
  * customer.shippingAddress.city
- * 
- * - *

- * - *
- * 
+ *
+ * }
+ *

+ *

{@code
+ *
  * // get a list of entities (query execution statistics)
- * 
- * List<Order> orders =
+ *
+ * List orders =
  *     Ebean.find(Order.class).findList();
- * 
+ *
  * // Apply a filter...
- * 
- * List<Order> filteredOrders =
+ *
+ * List filteredOrders =
  *     Ebean.filter(Order.class)
- *         .startsWith("customer.name", "Rob")
- *         .eq("customer.shippingAddress.city", "Auckland")
+ *         .startsWith("customer.name", "Rob")
+ *         .eq("customer.shippingAddress.city", "Auckland")
  *         .filter(orders);
- * 
- * 
- * - * @param - * the entity bean type + * + * }
+ * + * @param the entity bean type */ public interface Filter { @@ -189,9 +188,9 @@ public interface Filter { *

* The sourceList will remain unmodified. *

- * + * * @return Returns a new list with the sorting and filters applied. */ List filter(List sourceList); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/Finder.java b/src/main/java/com/avaje/ebean/Finder.java index beacbea49..6cd7cf1bd 100644 --- a/src/main/java/com/avaje/ebean/Finder.java +++ b/src/main/java/com/avaje/ebean/Finder.java @@ -11,11 +11,10 @@ import java.util.List; * These 'finders' are a place to organise all the finder methods for that bean type * and specific finder methods are expected to be added (find by unique properties etc). *

- * *

Testing

*

- * For testing the mocki-ebean project has the ability to replace the finder implementation - * + * For testing the mocki-ebean project has the ability to replace the finder implementation + *

*

*
{@code
  *
@@ -61,7 +60,6 @@ public class Finder {
 
   /**
    * Create with the type of the entity bean.
-   *
    * 
{@code
    *
    * public class CustomerFinder extends Finder {
@@ -96,10 +94,8 @@ public class Finder {
 
   /**
    * Return the underlying 'default' EbeanServer.
-   *
    * 

* This provides full access to the API such as explicit transaction demarcation etc. - * */ public EbeanServer db() { return Ebean.getServer(serverName); @@ -110,9 +106,8 @@ public class Finder { *

* This is equivalent to {@link Ebean#getServer(String)} * - * @param server - * The name of the EbeanServer. If this is null then the default EbeanServer is - * returned. + * @param server The name of the EbeanServer. If this is null then the default EbeanServer is + * returned. */ public EbeanServer db(String server) { return Ebean.getServer(server); @@ -120,7 +115,6 @@ public class Finder { /** * Creates an entity reference for this ID. - * *

* Equivalent to {@link EbeanServer#getReference(Class, Object)} */ @@ -130,7 +124,6 @@ public class Finder { /** * Retrieves an entity by ID. - * *

* Equivalent to {@link EbeanServer#find(Class, Object)} */ diff --git a/src/main/java/com/avaje/ebean/FutureList.java b/src/main/java/com/avaje/ebean/FutureList.java index 105a8c411..34301d446 100644 --- a/src/main/java/com/avaje/ebean/FutureList.java +++ b/src/main/java/com/avaje/ebean/FutureList.java @@ -17,31 +17,30 @@ import java.util.concurrent.TimeoutException; *

* A simple example: *

- * *
{@code
+ *
  *  // create a query to find all orders
  * Query query = Ebean.find(Order.class);
- * 
+ *
  *  // execute the query in a background thread
  *  // immediately returning the futureList
  * FutureList futureList = query.findFutureList();
- * 
- *  // do something else ... 
- * 
+ *
+ *  // do something else ...
+ *
  * if (!futureList.isDone()){
  * 	// we can cancel the query execution. This will cancel
  * // the underlying query if that is supported by the JDBC
  * // driver and database
  * 	futureList.cancel(true);
  * }
- * 
- * 
+ *
  * if (!futureList.isCancelled()){
  * 	// wait for the query to finish and return the list
  * 	List list = futureList.get();
  * 	...
  * }
- * 
+ *
  * }
*/ public interface FutureList extends Future> { @@ -56,7 +55,6 @@ public interface FutureList extends Future> { * unchecked PersistenceException. * * @return The query list result - * * @throws PersistenceException when a InterruptedException or ExecutionException occurs. */ List getUnchecked(); @@ -66,8 +64,7 @@ public interface FutureList extends Future> { * and ExecutionException in the unchecked PersistenceException. * * @return The query list result - * - * @throws TimeoutException if the wait timed out + * @throws TimeoutException if the wait timed out * @throws PersistenceException if a InterruptedException or ExecutionException occurs. */ List getUnchecked(long timeout, TimeUnit unit) throws TimeoutException; diff --git a/src/main/java/com/avaje/ebean/FutureRowCount.java b/src/main/java/com/avaje/ebean/FutureRowCount.java index 36aa6ab33..959846796 100644 --- a/src/main/java/com/avaje/ebean/FutureRowCount.java +++ b/src/main/java/com/avaje/ebean/FutureRowCount.java @@ -8,7 +8,8 @@ import java.util.concurrent.Future; *

* It extends the java.util.concurrent.Future. *

- * + * + * @param the BeanType * @author rbygrave */ public interface FutureRowCount extends Future { diff --git a/src/main/java/com/avaje/ebean/Junction.java b/src/main/java/com/avaje/ebean/Junction.java index 35ec6aa90..8437f53e6 100644 --- a/src/main/java/com/avaje/ebean/Junction.java +++ b/src/main/java/com/avaje/ebean/Junction.java @@ -9,7 +9,6 @@ package com.avaje.ebean; *

* Note: where() always takes you to the top level WHERE expression list. *

- * *
{@code
  * Query q =
  *     Ebean.find(Person.class)
@@ -23,13 +22,13 @@ package com.avaje.ebean;
  *
  * // read as...
  * // where ( ((name like Rob%) or (status = NEW)) AND (id > 10) )
- * }
* + * }
*

* Note: endJunction() takes you to the parent expression list *

- * *
{@code
+ *
  * Query q =
  *     Ebean.find(Person.class)
  *       .where()
@@ -46,11 +45,9 @@ package com.avaje.ebean;
  * // read as...
  * // where ( ((name like Rob%) or (status = NEW)) AND (id > 10) )
  * }
- * *

* Example of a nested disjunction. *

- * *
{@code
  * Query q =
  *  Ebean.find(Customer.class)
@@ -96,6 +93,11 @@ public interface Junction extends Expression, ExpressionList {
      */
     NOT(" and ", "not ", false),
 
+    /**
+     * FILTER group (for internal use only).
+     */
+    FILTER("filter", "", true),
+
     /**
      * Text search AND group.
      */
diff --git a/src/main/java/com/avaje/ebean/Model.java b/src/main/java/com/avaje/ebean/Model.java
index f03e52706..af8fa20c6 100644
--- a/src/main/java/com/avaje/ebean/Model.java
+++ b/src/main/java/com/avaje/ebean/Model.java
@@ -13,31 +13,26 @@ import java.util.UUID;
 /**
  * A MappedSuperclass base class that provides convenience methods for inserting, updating and
  * deleting beans.
- * 
  * 

* By having your entity beans extend this it provides a 'Active Record' style programming model for * Ebean users. - * *

* Note that there is a avaje-ebeanorm-mocker project that enables you to use Mockito or similar * tools to still mock out the underlying 'default EbeanServer' for testing purposes. - * *

* You may choose not use this Model mapped superclass if you don't like the 'Active Record' style * or if you believe it 'pollutes' your entity beans. - * *

* You can use Dependency Injection like Guice or Spring to construct and wire a EbeanServer instance * and have that same instance used with this Model and Finder. The way that works is that when the * DI container creates the EbeanServer instance it can be registered with the Ebean singleton. In this * way the EbeanServer instance can be injected as per normal Guice / Spring dependency injection and * that same instance also used to support the Model and Finder active record style. - * *

* If you choose to use the Model mapped superclass you will probably also chose to additionally add * a {@link Find} as a public static field to complete the active record pattern and provide a * relatively nice clean way to write queries. - * + *

*

Typical common @MappedSuperclass

*
{@code
  *
@@ -58,7 +53,7 @@ import java.util.UUID;
  *       ...
  *
  * }
- * + *

*

Extend the Model

*
{@code
  *
@@ -78,7 +73,7 @@ import java.util.UUID;
  *     }
  *
  * }
- * + *

*

Modal: save()

*
{@code
  *
@@ -90,7 +85,7 @@ import java.util.UUID;
  *     customer.save();
  *
  * }
- * + *

*

Find byId

*
{@code
  *
@@ -98,7 +93,7 @@ import java.util.UUID;
  *     Customer customer = Customer.find.byId(42);
  *
  * }
- * + *

*

Find where

*
{@code
  *
@@ -115,39 +110,37 @@ public abstract class Model {
 
   /**
    * Return the underlying 'default' EbeanServer.
-   * 
    * 

* This provides full access to the API such as explicit transaction demarcation etc. - * *

* Example: *

{@code
    *
    * Transaction transaction = Customer.db().beginTransaction();
    * try {
-   * 
+   *
    *   // turn off cascade persist for this transaction
    *   transaction.setPersistCascade(false);
-   * 
+   *
    *   // extra control over jdbc batching for this transaction
    *   transaction.setBatchGetGeneratedKeys(false);
    *   transaction.setBatchMode(true);
    *   transaction.setBatchSize(20);
-   * 
+   *
    *   Customer customer = new Customer();
    *   customer.setName("Roberto");
    *   customer.save();
-   * 
+   *
    *   Customer otherCustomer = new Customer();
    *   otherCustomer.setName("Franko");
    *   otherCustomer.save();
-   * 
+   *
    *   transaction.commit();
-   * 
+   *
    * } finally {
    *   transaction.end();
    * }
-   * 
+   *
    * }
*/ public static EbeanServer db() { @@ -156,13 +149,11 @@ public abstract class Model { /** * Return a named EbeanServer that is typically different to the default server. - * *

* If you are using multiple databases then each database has a name and maps to a single * EbeanServer. You can use this method to get an EbeanServer for another database. - * - * @param server - * The name of the EbeanServer. If this is null then the default EbeanServer is returned. + * + * @param server The name of the EbeanServer. If this is null then the default EbeanServer is returned. */ public static EbeanServer db(String server) { return Ebean.getServer(server); @@ -176,16 +167,16 @@ public abstract class Model { *

* An unmodified bean that is saved or updated is normally skipped and this marks the bean as * dirty so that it is not skipped. - * + *

*

{@code
-   * 
+   *
    * Customer customer = Customer.find.byId(id);
-   * 
+   *
    * // mark the bean as dirty so that a save() or update() will
    * // increment the version property
    * customer.markAsDirty();
    * customer.save();
-   * 
+   *
    * }
* * @see EbeanServer#markAsDirty(Object) @@ -197,7 +188,7 @@ public abstract class Model { /** * Mark the property as unset or 'not loaded'. *

- * This would be used to specify a property that we did not wish to include in a stateless update. + * This would be used to specify a property that we did not wish to include in a stateless update. *

*
{@code
    *
@@ -215,12 +206,11 @@ public abstract class Model {
    * @param propertyName the name of the property on the bean to be marked as 'unset'
    */
   public void markPropertyUnset(String propertyName) {
-    ((EntityBean)this)._ebean_getIntercept().setPropertyLoaded(propertyName, false);
+    ((EntityBean) this)._ebean_getIntercept().setPropertyLoaded(propertyName, false);
   }
 
   /**
    * Insert or update this entity depending on its state.
-   * 
    * 

* Ebean will detect if this is a new bean or a previously fetched bean and perform either an * insert or an update based on that. @@ -319,6 +309,7 @@ public abstract class Model { * It should be preferred to use {@link Find} instead of Finder as that can use reflection to determine the class * literal type of the entity bean. *

+ * * @param type of the Id property * @param type of the entity bean */ @@ -326,7 +317,7 @@ public abstract class Model { /** * Create with the type of the entity bean. - * + *

*

{@code
      *
      * @Entity
@@ -336,11 +327,11 @@ public abstract class Model {
      *   ...
      *
      * }
- * + *

*

* The preferred approach is to instead use Find as below. This approach is more DRY in that it does * not require the class literal Customer.class to be passed into the constructor. - * + *

*

{@code
      *
      * @Entity
@@ -366,13 +357,13 @@ public abstract class Model {
 
   /**
    * Helper object for performing queries.
-   * 
+   * 

*

* Typically a Find instance is defined as a public static field on an entity bean class to provide a * nice way to write queries. - * + *

*

Example use:

- * + *

*

{@code
    *
    * @Entity
@@ -395,7 +386,7 @@ public abstract class Model {
    *         .findList();
    *
    * }
- * + *

*

Kotlin

* In Kotlin you would typically create Find as a companion object. *
{@code
@@ -404,12 +395,10 @@ public abstract class Model {
    *   companion object : Model.Find() {}
    *
    * }
- * @param - * The Id type. This is most often a {@link Long} but is also often a {@link UUID} or - * {@link String}. * - * @param - * The entity bean type + * @param The Id type. This is most often a {@link Long} but is also often a {@link UUID} or + * {@link String}. + * @param The entity bean type */ public static abstract class Find { @@ -427,11 +416,11 @@ public abstract class Model { * Creates a finder for entity of type T with ID of type I. *

* Typically you create Find as a public static field on each entity bean as the example below. - * + *

*

* Note that Find is an abstract class and hence {} is required. This is done so * that the type (class literal) of the entity bean can be derived from the generics parameter. - * + *

*

{@code
      *
      * @Entity
@@ -456,10 +445,10 @@ public abstract class Model {
      *        .findList();
      *
      * }
- * + *

*

Kotlin

* In Kotlin you would typically create it as a companion object. - * + *

*

{@code
      *
      *   // kotlin
@@ -470,7 +459,7 @@ public abstract class Model {
     @SuppressWarnings("unchecked")
     public Find() {
       this.serverName = null;
-      this.type = (Class)ClassUtil.getSecondArgumentType(getClass());
+      this.type = (Class) ClassUtil.getSecondArgumentType(getClass());
     }
 
     /**
@@ -483,10 +472,9 @@ public abstract class Model {
 
     /**
      * Return the underlying 'default' EbeanServer.
-     * 
+     * 

*

* This provides full access to the API such as explicit transaction demarcation etc. - * */ public EbeanServer db() { return Ebean.getServer(serverName); @@ -496,10 +484,9 @@ public abstract class Model { * Return typically a different EbeanServer to the default. *

* This is equivalent to {@link Ebean#getServer(String)} - * - * @param server - * The name of the EbeanServer. If this is null then the default EbeanServer is - * returned. + * + * @param server The name of the EbeanServer. If this is null then the default EbeanServer is + * returned. */ public EbeanServer db(String server) { return Ebean.getServer(server); @@ -507,12 +494,12 @@ public abstract class Model { /** * Creates a Finder for the named EbeanServer. - * + *

*

* Create and return a new Finder for a different server. */ public Finder on(String server) { - return new Finder(server, type); + return new Finder<>(server, type); } /** @@ -526,7 +513,7 @@ public abstract class Model { /** * Retrieves all entities of the given type. - * + *

*

* This is the same as (synonym for) {@link #findList()} */ @@ -536,7 +523,7 @@ public abstract class Model { /** * Retrieves an entity by ID. - * + *

*

* Equivalent to {@link EbeanServer#find(Class, Object)} */ @@ -547,7 +534,7 @@ public abstract class Model { /** * Creates an entity reference for this ID. - * + *

*

* Equivalent to {@link EbeanServer#getReference(Class, Object)} */ @@ -585,7 +572,7 @@ public abstract class Model { /** * Returns the next identity value. - * + * * @see EbeanServer#nextId(Class) */ @SuppressWarnings("unchecked") @@ -693,6 +680,7 @@ public abstract class Model { /** * Deprecated in favor of findCount(). + * * @deprecated */ public int findRowCount() { @@ -829,7 +817,7 @@ public abstract class Model { /** * Sets the ID value to query. - * + *

*

* Use this to perform a find byId query but with additional control over the query such as * using select and fetch to control what parts of the object graph are returned. @@ -858,7 +846,7 @@ public abstract class Model { /** * Create a query with the select with "for update" specified. - * + *

*

* This will typically create row level database locks on the selected rows. */ @@ -895,4 +883,4 @@ public abstract class Model { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/OrderBy.java b/src/main/java/com/avaje/ebean/OrderBy.java index ff1b8cc1c..b62041cbf 100644 --- a/src/main/java/com/avaje/ebean/OrderBy.java +++ b/src/main/java/com/avaje/ebean/OrderBy.java @@ -28,9 +28,9 @@ public final class OrderBy implements Serializable { * Create an empty OrderBy with no associated query. */ public OrderBy() { - this.list = new ArrayList(3); + this.list = new ArrayList<>(3); } - + private OrderBy(List list) { this.list = list; } @@ -52,7 +52,7 @@ public final class OrderBy implements Serializable { */ public OrderBy(Query query, String orderByClause) { this.query = query; - this.list = new ArrayList(3); + this.list = new ArrayList<>(3); parse(orderByClause); } @@ -60,8 +60,8 @@ public final class OrderBy implements Serializable { * Reverse the ascending/descending order on all the properties. */ public void reverse() { - for (int i = 0; i < list.size(); i++) { - list.get(i).reverse(); + for (Property aList : list) { + aList.reverse(); } } @@ -88,8 +88,8 @@ public final class OrderBy implements Serializable { */ public boolean containsProperty(String propertyName) { - for (int i = 0; i < list.size(); i++) { - if (propertyName.equals(list.get(i).getProperty())) { + for (Property aList : list) { + if (propertyName.equals(aList.getProperty())) { return true; } } @@ -100,13 +100,13 @@ public final class OrderBy implements Serializable { * Return a copy of this OrderBy with the path trimmed. */ public OrderBy copyWithTrim(String path) { - List newList = new ArrayList(list.size()); - for (int i = 0; i < list.size(); i++) { - newList.add(list.get(i).copyWithTrim(path)); + List newList = new ArrayList<>(list.size()); + for (Property aList : list) { + newList.add(aList.copyWithTrim(path)); } - return new OrderBy(newList); + return new OrderBy<>(newList); } - + /** * Return the properties for this OrderBy. */ @@ -141,9 +141,9 @@ public final class OrderBy implements Serializable { */ public OrderBy copy() { - OrderBy copy = new OrderBy(); - for (int i = 0; i < list.size(); i++) { - copy.add(list.get(i).copy()); + OrderBy copy = new OrderBy<>(); + for (Property aList : list) { + copy.add(aList.copy()); } return copy; } @@ -192,7 +192,7 @@ public final class OrderBy implements Serializable { if (!(obj instanceof OrderBy)) { return false; } - + OrderBy e = (OrderBy) obj; return e.list.equals(list); } @@ -294,7 +294,7 @@ public final class OrderBy implements Serializable { sb.append(" ").append("desc"); } sb.append(" ").append(nulls).append(" ").append(highLow); - return sb.toString(); + return sb.toString(); } } @@ -356,8 +356,8 @@ public final class OrderBy implements Serializable { } String[] chunks = orderByClause.split(","); - for (int i = 0; i < chunks.length; i++) { - String[] pairs = chunks[i].split(" "); + for (String chunk : chunks) { + String[] pairs = chunk.split(" "); Property p = parseProperty(pairs); if (p != null) { list.add(p); @@ -370,10 +370,10 @@ public final class OrderBy implements Serializable { return null; } - ArrayList wordList = new ArrayList(pairs.length); - for (int i = 0; i < pairs.length; i++) { - if (!isEmptyString(pairs[i])) { - wordList.add(pairs[i]); + ArrayList wordList = new ArrayList<>(pairs.length); + for (String pair : pairs) { + if (!isEmptyString(pair)) { + wordList.add(pair); } } if (wordList.isEmpty()) { diff --git a/src/main/java/com/avaje/ebean/PagedList.java b/src/main/java/com/avaje/ebean/PagedList.java index 3bd67beae..253641784 100644 --- a/src/main/java/com/avaje/ebean/PagedList.java +++ b/src/main/java/com/avaje/ebean/PagedList.java @@ -8,7 +8,7 @@ import java.util.concurrent.Future; *

* The benefit of using PagedList over just using the normal Query with * {@link Query#setFirstRow(int)} and {@link Query#setMaxRows(int)} is that it additionally wraps - * functionality that can call {@link Query#findFutureRowCount()} to determine total row count, + * functionality that can call {@link Query#findFutureCount()} to determine total row count, * total page count etc. *

*

@@ -16,8 +16,7 @@ import java.util.concurrent.Future; * the query. This translates into SQL that uses limit offset, rownum or row_number function to * limit the result set. *

- * - * + *

*

Example: typical use including total row count

*
{@code
  *
@@ -43,8 +42,7 @@ import java.util.concurrent.Future;
  *     int totalRowCount = pagedList.getTotalRowCount();
  *
  * }
- * - * + *

*

Example: No total row count required

*
{@code
  *
@@ -57,9 +55,7 @@ import java.util.concurrent.Future;
  *
  * }
* - * @param - * the entity bean type - * + * @param the entity bean type * @see Query#findPagedList() */ public interface PagedList { @@ -79,7 +75,6 @@ public interface PagedList { * int totalRowCount = pagedList.getTotalRowCount(); * * }
- * *

* Also note that using loadRowCount() and getTotalRowCount() rather than getFutureRowCount() * means that exceptions ExecutionException, InterruptedException, TimeoutException are instead @@ -192,11 +187,8 @@ public interface PagedList { * the total row count query if it has not already been invoked. *

* - * @param to - * String to put between the first and last row - * @param of - * String to put between the last row and the total row count - * + * @param to String to put between the first and last row + * @param of String to put between the last row and the total row count * @return String of the format XtoYofZ. */ String getDisplayXtoYofZ(String to, String of); diff --git a/src/main/java/com/avaje/ebean/PersistenceIOException.java b/src/main/java/com/avaje/ebean/PersistenceIOException.java index 08c26556f..bef4da6da 100644 --- a/src/main/java/com/avaje/ebean/PersistenceIOException.java +++ b/src/main/java/com/avaje/ebean/PersistenceIOException.java @@ -7,6 +7,8 @@ import javax.persistence.PersistenceException; */ public class PersistenceIOException extends PersistenceException { + private static final long serialVersionUID = -7630050437148176148L; + public PersistenceIOException(String msg, Exception cause) { super(msg, cause); } diff --git a/src/main/java/com/avaje/ebean/Query.java b/src/main/java/com/avaje/ebean/Query.java index a3fc51e58..d09d53af8 100644 --- a/src/main/java/com/avaje/ebean/Query.java +++ b/src/main/java/com/avaje/ebean/Query.java @@ -724,7 +724,7 @@ public interface Query { /** * Execute the query returning a list of values for a single property. - * + *

*

Example 1:

*
{@code
    *
@@ -735,7 +735,7 @@ public interface Query {
    *      .findSingleAttributeList();
    *
    * }
- * + *

*

Example 2:

*
{@code
    *
diff --git a/src/main/java/com/avaje/ebean/QueryEachConsumer.java b/src/main/java/com/avaje/ebean/QueryEachConsumer.java
index f7de39953..6aa3f54fa 100644
--- a/src/main/java/com/avaje/ebean/QueryEachConsumer.java
+++ b/src/main/java/com/avaje/ebean/QueryEachConsumer.java
@@ -11,7 +11,7 @@ package com.avaje.ebean;
  * all the beans in the query result to be held in memory at once. This makes
  * QueryResultVisitor useful for processing large queries.
  * 

- * + *

*

{@code
  *
  * Query query = server.find(Customer.class)
@@ -25,17 +25,15 @@ package com.avaje.ebean;
  * });
  *
  * }
- * - * @param - * the type of entity bean being queried. + * + * @param the type of entity bean being queried. */ public interface QueryEachConsumer { /** * Process the bean. - * - * @param bean - * the entity bean to process + * + * @param bean the entity bean to process */ void accept(T bean); } diff --git a/src/main/java/com/avaje/ebean/QueryEachWhileConsumer.java b/src/main/java/com/avaje/ebean/QueryEachWhileConsumer.java index 251fd4326..54dfb9597 100644 --- a/src/main/java/com/avaje/ebean/QueryEachWhileConsumer.java +++ b/src/main/java/com/avaje/ebean/QueryEachWhileConsumer.java @@ -12,23 +12,24 @@ package com.avaje.ebean; * QueryResultVisitor useful for processing large queries. *

*

- *

+ * 
{@code
  *
- * Query<Customer> query = server.find(Customer.class)
- *     .fetch("contacts", new FetchConfig().query(2))
- *     .where().gt("id", 0)
- *     .orderBy("id")
+ * Query query = server.find(Customer.class)
+ *     .fetchQuery("contacts")
+ *     .where().gt("id", 0)
+ *     .orderBy("id")
  *     .setMaxRows(2);
  *
  * query.findEachWhile((Customer customer) -> {
  *
  *     // do something with customer
- *     System.out.println("-- visit " + customer);
+ *     System.out.println("-- visit " + customer);
  *
  *     // return true to continue processing or false to stop
  *     return (customer.getId() < 40);
  * });
- * 
+ * + * }
* * @param the type of entity bean being queried. */ diff --git a/src/main/java/com/avaje/ebean/QueryIterator.java b/src/main/java/com/avaje/ebean/QueryIterator.java index 23bfaea55..96787bd3f 100644 --- a/src/main/java/com/avaje/ebean/QueryIterator.java +++ b/src/main/java/com/avaje/ebean/QueryIterator.java @@ -19,9 +19,8 @@ import java.util.Iterator; * Remember that with {@link QueryIterator} you must call {@link QueryIterator#close()} * when you have finished iterating the results (typically in a finally block). *

- * *
{@code
- * 
+ *
  *  Query query = server.find(Customer.class)
  *     .where().gt("id", 0)
  *     .orderBy("id")
@@ -39,9 +38,8 @@ import java.util.Iterator;
  *  }
  *
  * }
- * - * @param - * the type of entity bean in the iteration + * + * @param the type of entity bean in the iteration */ public interface QueryIterator extends Iterator, java.io.Closeable { diff --git a/src/main/java/com/avaje/ebean/RawSql.java b/src/main/java/com/avaje/ebean/RawSql.java index a5488de72..b5ca778d2 100644 --- a/src/main/java/com/avaje/ebean/RawSql.java +++ b/src/main/java/com/avaje/ebean/RawSql.java @@ -1,10 +1,15 @@ package com.avaje.ebean; +import com.avaje.ebean.util.CamelCaseHelper; + import java.io.Serializable; import java.sql.ResultSet; -import java.util.*; - -import com.avaje.ebean.util.CamelCaseHelper; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** * Used to build object graphs based on a raw SQL statement (rather than @@ -51,39 +56,38 @@ import com.avaje.ebean.util.CamelCaseHelper; * to hold the values for the aggregate functions (sum etc) and a @OneToOne * to Order. *

- * + *

*

Example OrderAggregate

- * *
{@code
  *  ...
  *  // @Sql indicates to that this bean
  *  // is based on RawSql rather than a table
- * 
+ *
  * @Entity
  * @Sql
  * public class OrderAggregate {
- * 
+ *
  *  @OneToOne
  *  Order order;
- *      
+ *
  *  Double totalAmount;
- *  
+ *
  *  Double totalItems;
- *  
+ *
  *  // getters and setters
  *  ...
  *
  * }
- * + *

*

Example 1:

- * + *

*

{@code
  *
  *   String sql = " select order_id, o.status, c.id, c.name, sum(d.order_qty*d.unit_price) as totalAmount"
  *     + " from o_order o"
  *     + " join o_customer c on c.id = o.kcustomer_id "
  *     + " join o_order_detail d on d.order_id = o.id " + " group by order_id, o.status ";
- * 
+ *
  *   RawSql rawSql = RawSqlBuilder.parse(sql)
  *     // map the sql result columns to bean properties
  *     .columnMapping("order_id", "order.id")
@@ -93,35 +97,34 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *     // we don't need to map this one due to the sql column alias
  *     // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount")
  *     .create();
- * 
+ *
  *   List list = Ebean.find(OrderAggregate.class)
  *       .setRawSql(rawSql)
  *       .where().gt("order.id", 0)
  *       .having().gt("totalAmount", 20)
  *       .findList();
- * 
+ *
  *
  * }
- * + *

*

Example 2:

- * *

* The following example uses a FetchConfig().query() so that after the initial * RawSql query is executed Ebean executes a secondary query to fetch the * associated order status, orderDate along with the customer name. *

- * + *

*

{@code
  *
  *  String sql = " select order_id, 'ignoreMe', sum(d.order_qty*d.unit_price) as totalAmount "
  *     + " from o_order_detail d"
  *     + " group by order_id ";
- * 
+ *
  *   RawSql rawSql = RawSqlBuilder.parse(sql)
  *     .columnMapping("order_id", "order.id")
  *     .columnMappingIgnore("'ignoreMe'")
  *     .create();
- * 
+ *
  *   List orders = Ebean.find(OrderAggregate.class)
  *     .setRawSql(rawSql)
  *     .fetch("order", "status,orderDate", new FetchConfig().query())
@@ -131,13 +134,12 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *     .order().desc("totalAmount")
  *     .setMaxRows(10)
  *     .findList();
- * 
+ *
  * }
- * - * + *

*

Example 3: tableAliasMapping

*

- * Instead of mapping each column you can map each table alias to a path using tableAliasMapping(). + * Instead of mapping each column you can map each table alias to a path using tableAliasMapping(). *

*
{@code
  *
@@ -162,19 +164,17 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *       .findList();
  *
  * }
- * - * + *

*

* Note that lazy loading also works with object graphs built with RawSql. *

- * */ public final class RawSql implements Serializable { private static final long serialVersionUID = 1L; private final ResultSet resultSet; - + private final Sql sql; private final ColumnMapping columnMapping; @@ -192,7 +192,7 @@ public final class RawSql implements Serializable { this.sql = null; this.columnMapping = new ColumnMapping(propertyNames); } - + protected RawSql(ResultSet resultSet, Sql sql, ColumnMapping columnMapping) { this.resultSet = resultSet; this.sql = sql; @@ -214,7 +214,7 @@ public final class RawSql implements Serializable { String unParsedSql = (sql == null) ? "" : sql.unparsedSql; return new Key(parsed, unParsedSql, columnMapping); } - + /** * Return the resultSet if this is a ResultSet based RawSql. */ @@ -278,7 +278,7 @@ public final class RawSql implements Serializable { * Construct for parsed SQL. */ protected Sql(String unparsedSql, String preFrom, String preWhere, boolean andWhereExpr, - String preHaving, boolean andHavingExpr, String orderByPrefix, String orderBy, boolean distinct) { + String preHaving, boolean andHavingExpr, String orderByPrefix, String orderBy, boolean distinct) { this.unparsedSql = unparsedSql; this.parsed = true; @@ -296,8 +296,7 @@ public final class RawSql implements Serializable { if (!parsed) { return "unparsed[" + unparsedSql + "]"; } - return "select[" + preFrom + "] preWhere[" + preWhere + "] preHaving[" + preHaving - + "] orderBy[" + orderBy + "]"; + return "select[" + preFrom + "] preWhere[" + preWhere + "] preHaving[" + preHaving + "] orderBy[" + orderBy + "]"; } public boolean isDistinct() { @@ -386,7 +385,7 @@ public final class RawSql implements Serializable { private final LinkedHashMap dbColumnMap; private final Map propertyMap; - + private final Map propertyColumnMap; private final boolean parsed; @@ -401,9 +400,8 @@ public final class RawSql implements Serializable { this.parsed = true; this.propertyMap = null; this.propertyColumnMap = null; - this.dbColumnMap = new LinkedHashMap(); - for (int i = 0; i < columns.size(); i++) { - Column c = columns.get(i); + this.dbColumnMap = new LinkedHashMap<>(); + for (Column c : columns) { dbColumnMap.put(c.getDbColumnKey(), c); } } @@ -416,9 +414,9 @@ public final class RawSql implements Serializable { this.parsed = false; this.propertyMap = null; this.propertyColumnMap = null; - this.dbColumnMap = new LinkedHashMap(); + this.dbColumnMap = new LinkedHashMap<>(); } - + /** * Construct for ResultSet use. */ @@ -426,7 +424,7 @@ public final class RawSql implements Serializable { this.immutable = false; this.parsed = false; this.propertyMap = null; - this.dbColumnMap = new LinkedHashMap(); + this.dbColumnMap = new LinkedHashMap<>(); int pos = 0; for (String prop : propertyNames) { @@ -443,8 +441,8 @@ public final class RawSql implements Serializable { this.parsed = parsed; this.dbColumnMap = dbColumnMap; - HashMap pcMap = new HashMap(); - HashMap pMap = new HashMap(); + HashMap pcMap = new HashMap<>(); + HashMap pMap = new HashMap<>(); for (Column c : dbColumnMap.values()) { pMap.put(c.getPropertyName(), c.getDbColumn()); @@ -476,9 +474,8 @@ public final class RawSql implements Serializable { /** * Creates an immutable copy of this ColumnMapping. - * - * @throws IllegalStateException - * when a propertyName has not been defined for a column. + * + * @throws IllegalStateException when a propertyName has not been defined for a column. */ protected ColumnMapping createImmutableCopy() { @@ -567,7 +564,7 @@ public final class RawSql implements Serializable { */ public void tableAliasMapping(String tableAlias, String path) { - String startMatch = tableAlias+"."; + String startMatch = tableAlias + "."; for (Map.Entry entry : dbColumnMap.entrySet()) { if (entry.getKey().startsWith(startMatch)) { entry.getValue().tableAliasMapping(path); @@ -720,8 +717,8 @@ public final class RawSql implements Serializable { Key that = (Key) o; return parsed == that.parsed - && columnMapping.equals(that.columnMapping) - && unParsedSql.equals(that.unParsedSql); + && columnMapping.equals(that.columnMapping) + && unParsedSql.equals(that.unParsedSql); } @Override diff --git a/src/main/java/com/avaje/ebean/RawSqlBuilder.java b/src/main/java/com/avaje/ebean/RawSqlBuilder.java index 45ab6880c..0c4e1ed3c 100644 --- a/src/main/java/com/avaje/ebean/RawSqlBuilder.java +++ b/src/main/java/com/avaje/ebean/RawSqlBuilder.java @@ -1,17 +1,17 @@ package com.avaje.ebean; -import java.sql.ResultSet; - import com.avaje.ebean.RawSql.ColumnMapping; import com.avaje.ebean.RawSql.Sql; +import java.sql.ResultSet; + /** * Builds RawSql instances from a SQL string and column mappings. *

* Note that RawSql can also be defined in ebean-orm.xml files and be used as a * named query. *

- * + * * @see RawSql */ public class RawSqlBuilder { @@ -22,7 +22,7 @@ public class RawSqlBuilder { public static final String IGNORE_COLUMN = "$$_IGNORE_COLUMN_$$"; private final ResultSet resultSet; - + private final Sql sql; private final ColumnMapping columnMapping; @@ -37,7 +37,7 @@ public class RawSqlBuilder { public static RawSql resultSet(ResultSet resultSet, String... propertyNames) { return new RawSql(resultSet, propertyNames); } - + /** * Return an unparsed RawSqlBuilder. Unlike a parsed one this query can not be * modified - so no additional WHERE or HAVING expressions can be added to @@ -70,7 +70,7 @@ public class RawSqlBuilder { ColumnMapping mapping = DRawSqlColumnsParser.parse(select); return new RawSqlBuilder(sql2, mapping); } - + private RawSqlBuilder(Sql sql, ColumnMapping columnMapping) { this.sql = sql; this.columnMapping = columnMapping; @@ -83,11 +83,9 @@ public class RawSqlBuilder { * For Unparsed SQL the columnMapping MUST be defined in the same order that * the columns appear in the SQL statement. *

- * - * @param dbColumn - * the DB column that we are mapping to a bean property - * @param propertyName - * the bean property that we are mapping the DB column to. + * + * @param dbColumn the DB column that we are mapping to a bean property + * @param propertyName the bean property that we are mapping the DB column to. */ public RawSqlBuilder columnMapping(String dbColumn, String propertyName) { columnMapping.columnMapping(dbColumn, propertyName); @@ -130,6 +128,4 @@ public class RawSqlBuilder { return sql; } - - } diff --git a/src/main/java/com/avaje/ebean/SqlQuery.java b/src/main/java/com/avaje/ebean/SqlQuery.java index 58e4b721d..5a817bc16 100644 --- a/src/main/java/com/avaje/ebean/SqlQuery.java +++ b/src/main/java/com/avaje/ebean/SqlQuery.java @@ -18,23 +18,22 @@ import java.util.List; * The returned SqlRow objects are similar to a LinkedHashMap with some type * conversion support added. *

- * + *

*

{@code
  *
  *   // its typically a good idea to use a named query
  *   // and put the sql in the orm.xml instead of in your code
- * 
+ *
  *   String sql = "select id, name from customer where name like :name and status_code = :status";
- * 
+ *
  *   SqlQuery sqlQuery = Ebean.createSqlQuery(sql);
  *   sqlQuery.setParameter("name", "Acme%");
  *   sqlQuery.setParameter("status", "ACTIVE");
- * 
+ *
  *   // execute the query returning a List of MapBean objects
  *   List list = sqlQuery.findList();
  *
  * }
- * */ public interface SqlQuery extends Serializable { @@ -98,9 +97,8 @@ public interface SqlQuery extends Serializable { * preparedStatement. If the timeout occurs an exception will be thrown - this * will be a SQLException wrapped up in a PersistenceException. *

- * - * @param secs - * the query timeout limit in seconds. Zero means there is no limit. + * + * @param secs the query timeout limit in seconds. Zero means there is no limit. */ SqlQuery setTimeout(int secs); diff --git a/src/main/java/com/avaje/ebean/SqlUpdate.java b/src/main/java/com/avaje/ebean/SqlUpdate.java index c02e89485..720d74159 100644 --- a/src/main/java/com/avaje/ebean/SqlUpdate.java +++ b/src/main/java/com/avaje/ebean/SqlUpdate.java @@ -16,19 +16,21 @@ package com.avaje.ebean; * notify Ebean of external changes and enable Ebean to maintain it's "L2" * server cache. *

- * - *
- * // example that uses 'named' parameters 
- * String s = "UPDATE f_topic set post_count = :count where id = :id"
+ * 

+ *

{@code
+ *
+ * // example that uses 'named' parameters
+ * String s = "UPDATE f_topic set post_count = :count where id = :id";
  * SqlUpdate update = Ebean.createSqlUpdate(s);
- * update.setParameter("id", 1);
- * update.setParameter("count", 50);
- * 
+ * update.setParameter("id", 1);
+ * update.setParameter("count", 50);
+ *
  * int modifiedCount = Ebean.execute(update);
- * 
- * String msg = "There were " + modifiedCount + " rows updated"
- * 
- * + * + * String msg = "There were " + modifiedCount + " rows updated"; + * + * }
+ * * @see Update * @see SqlQuery * @see CallableSql @@ -47,7 +49,7 @@ public interface SqlUpdate { * {@link Transaction#setBatchMode(boolean)} and * {@link Transaction#setBatchSize(int)}. *

- * + * * @see com.avaje.ebean.Ebean#execute(SqlUpdate) */ int execute(); diff --git a/src/main/java/com/avaje/ebean/Transaction.java b/src/main/java/com/avaje/ebean/Transaction.java index c05434b5c..ee453f159 100644 --- a/src/main/java/com/avaje/ebean/Transaction.java +++ b/src/main/java/com/avaje/ebean/Transaction.java @@ -62,10 +62,10 @@ public interface Transaction extends Closeable { *

*

Functions/h3> *
    - *
  • Flush the JDBC batch buffer
  • - *
  • Call commit on the underlying JDBC connection
  • - *
  • Trigger any registered TransactionCallbacks
  • - *
  • Perform post-commit processing updating L2 cache, ElasticSearch etc
  • + *
  • Flush the JDBC batch buffer
  • + *
  • Call commit on the underlying JDBC connection
  • + *
  • Trigger any registered TransactionCallbacks
  • + *
  • Perform post-commit processing updating L2 cache, ElasticSearch etc
  • *
*/ void commitAndContinue() throws RollbackException; @@ -78,12 +78,12 @@ public interface Transaction extends Closeable { *

*

Functions/h3> *
    - *
  • Flush the JDBC batch buffer
  • - *
  • Call commit on the underlying JDBC connection
  • - *
  • Trigger any registered TransactionCallbacks
  • - *
  • Perform post-commit processing updating L2 cache, ElasticSearch etc
  • - *
  • Close any underlying resources, closing the underlying JDBC connection
  • - *
  • Mark the transaction as "Inactive"
  • + *
  • Flush the JDBC batch buffer
  • + *
  • Call commit on the underlying JDBC connection
  • + *
  • Trigger any registered TransactionCallbacks
  • + *
  • Perform post-commit processing updating L2 cache, ElasticSearch etc
  • + *
  • Close any underlying resources, closing the underlying JDBC connection
  • + *
  • Mark the transaction as "Inactive"
  • *
*/ void commit() throws RollbackException; @@ -95,10 +95,10 @@ public interface Transaction extends Closeable { *

*

Functions/h3> *
    - *
  • Call rollback on the underlying JDBC connection
  • - *
  • Trigger any registered TransactionCallbacks
  • - *
  • Close any underlying resources, closing the underlying JDBC connection
  • - *
  • Mark the transaction as "Inactive"
  • + *
  • Call rollback on the underlying JDBC connection
  • + *
  • Trigger any registered TransactionCallbacks
  • + *
  • Close any underlying resources, closing the underlying JDBC connection
  • + *
  • Mark the transaction as "Inactive"
  • *
*/ void rollback() throws PersistenceException; @@ -136,10 +136,10 @@ public interface Transaction extends Closeable { /** * Set the behavior for document store updates on this transaction. *

- * For example, set the mode to DocStoreEvent.IGNORE for this transaction and - * then any changes via this transaction are not sent to the doc store. This - * would be used when doing large bulk inserts into the database and we want - * to control how that is sent to the document store. + * For example, set the mode to DocStoreEvent.IGNORE for this transaction and + * then any changes via this transaction are not sent to the doc store. This + * would be used when doing large bulk inserts into the database and we want + * to control how that is sent to the document store. *

*/ void setDocStoreMode(DocStoreMode mode); @@ -147,11 +147,11 @@ public interface Transaction extends Closeable { /** * Set the batch size to use for sending messages to the document store. *

- * You might set this if you know the changes in this transaction result in especially large or - * especially small payloads and want to adjust the batch size to match. + * You might set this if you know the changes in this transaction result in especially large or + * especially small payloads and want to adjust the batch size to match. *

*

- * Setting this overrides the default of {@link DocStoreConfig#getBulkBatchSize()} + * Setting this overrides the default of {@link DocStoreConfig#getBulkBatchSize()} *

*/ void setDocStoreBatchSize(int batchSize); @@ -197,7 +197,7 @@ public interface Transaction extends Closeable { * Refer to {@link ServerConfig#setSkipCacheAfterWrite(boolean)} for configuring the default behavior * for using the L2 bean cache in transactions spanning multiple query/persist requests. *

- * + *

*

{@code
    *
    *   // assume Customer has L2 bean caching enabled ...
@@ -279,23 +279,23 @@ public interface Transaction extends Closeable {
    * 

* Example: batch processing executing every 3 rows *

- * + *

*

{@code
    *
    * String data = "This is a simple test of the batch processing"
    *             + " mode and the transaction execute batch method";
-   * 
+   *
    * String[] da = data.split(" ");
-   * 
+   *
    * String sql = "{call sp_t3(?,?)}";
-   * 
+   *
    * CallableSql cs = new CallableSql(sql);
    * cs.registerOut(2, Types.INTEGER);
-   * 
+   *
    * // (optional) inform eBean this stored procedure
    * // inserts into a table called sp_test
    * cs.addModification("sp_test", true, false, false);
-   * 
+   *
    * Transaction txn = ebeanServer.beginTransaction();
    * txn.setBatchMode(true);
    * txn.setBatchSize(3);
@@ -304,16 +304,15 @@ public interface Transaction extends Closeable {
    *     cs.setParameter(1, da[i]);
    *     ebeanServer.execute(cs);
    *   }
-   * 
+   *
    *   // NB: commit implicitly flushes
    *   txn.commit();
-   * 
+   *
    * } finally {
    *   txn.end();
    * }
    *
    * }
- * */ void setBatchMode(boolean useBatch); @@ -325,7 +324,6 @@ public interface Transaction extends Closeable { *

* * @param persistBatchMode the batch mode to use for this transaction - * * @see com.avaje.ebean.config.ServerConfig#setPersistBatch(com.avaje.ebean.config.PersistBatch) */ void setBatch(PersistBatch persistBatchMode); @@ -347,7 +345,6 @@ public interface Transaction extends Closeable { *

* * @param batchOnCascadeMode the batch mode to use per save(), insert(), update() or delete() - * * @see com.avaje.ebean.config.ServerConfig#setPersistBatchOnCascade(com.avaje.ebean.config.PersistBatch) */ void setBatchOnCascade(PersistBatch batchOnCascadeMode); diff --git a/src/main/java/com/avaje/ebean/TxCallable.java b/src/main/java/com/avaje/ebean/TxCallable.java index 204b1774a..3e4128b7a 100644 --- a/src/main/java/com/avaje/ebean/TxCallable.java +++ b/src/main/java/com/avaje/ebean/TxCallable.java @@ -12,24 +12,26 @@ package com.avaje.ebean; *

* See also {@link TxRunnable}. *

- * - *
- * Ebean.execute(new TxCallable<String>() {
+ * 

+ *

{@code
+ *
+ * Ebean.execute(new TxCallable() {
  *   public String call() {
  *     User u1 = Ebean.find(User.class, 1);
  *     User u2 = Ebean.find(User.class, 2);
- * 
- *     u1.setName("u1 mod");
- *     u2.setName("u2 mod");
- * 
+ *
+ *     u1.setName("u1 mod");
+ *     u2.setName("u2 mod");
+ *
  *     Ebean.save(u1);
  *     Ebean.save(u2);
- * 
+ *
  *     return u1.getEmail();
  *   }
  * });
- * 
- * + * + * }
+ * * @see TxRunnable */ public interface TxCallable { diff --git a/src/main/java/com/avaje/ebean/TxIsolation.java b/src/main/java/com/avaje/ebean/TxIsolation.java index 8c0394c29..754959bbf 100644 --- a/src/main/java/com/avaje/ebean/TxIsolation.java +++ b/src/main/java/com/avaje/ebean/TxIsolation.java @@ -12,7 +12,7 @@ import java.sql.Connection; * This can be used with TxScope to define transactional scopes to execute * method within. *

- * + * * @see TxScope */ public enum TxIsolation { @@ -74,26 +74,26 @@ public enum TxIsolation { public static TxIsolation fromLevel(int connectionIsolationLevel) { switch (connectionIsolationLevel) { - case Connection.TRANSACTION_READ_UNCOMMITTED: - return TxIsolation.READ_UNCOMMITTED; + case Connection.TRANSACTION_READ_UNCOMMITTED: + return TxIsolation.READ_UNCOMMITTED; - case Connection.TRANSACTION_READ_COMMITTED: - return TxIsolation.READ_COMMITED; + case Connection.TRANSACTION_READ_COMMITTED: + return TxIsolation.READ_COMMITED; - case Connection.TRANSACTION_REPEATABLE_READ: - return TxIsolation.REPEATABLE_READ; + case Connection.TRANSACTION_REPEATABLE_READ: + return TxIsolation.REPEATABLE_READ; - case Connection.TRANSACTION_SERIALIZABLE: - return TxIsolation.SERIALIZABLE; + case Connection.TRANSACTION_SERIALIZABLE: + return TxIsolation.SERIALIZABLE; - case Connection.TRANSACTION_NONE: - return TxIsolation.NONE; + case Connection.TRANSACTION_NONE: + return TxIsolation.NONE; - case -1: - return TxIsolation.DEFAULT; + case -1: + return TxIsolation.DEFAULT; - default: - throw new RuntimeException("Unknown isolation level " + connectionIsolationLevel); + default: + throw new RuntimeException("Unknown isolation level " + connectionIsolationLevel); } } diff --git a/src/main/java/com/avaje/ebean/TxRunnable.java b/src/main/java/com/avaje/ebean/TxRunnable.java index f3bc724cc..2ae3009a2 100644 --- a/src/main/java/com/avaje/ebean/TxRunnable.java +++ b/src/main/java/com/avaje/ebean/TxRunnable.java @@ -8,26 +8,27 @@ package com.avaje.ebean; *

* See also {@link TxCallable}. *

- * - *
- * 
+ * 

+ *

{@code
+ *
  * // this run method runs in a transaction scope
  * // which by default is TxScope.REQUIRED
- * 
+ *
  * Ebean.execute(new TxRunnable() {
  *   public void run() {
  *     User u1 = Ebean.find(User.class, 1);
  *     User u2 = Ebean.find(User.class, 2);
- * 
- *     u1.setName("u1 mod");
- *     u2.setName("u2 mod");
- * 
+ *
+ *     u1.setName("u1 mod");
+ *     u2.setName("u2 mod");
+ *
  *     Ebean.save(u1);
  *     Ebean.save(u2);
  *   }
  * });
- * 
- * + * + * }
+ * * @see TxCallable */ public interface TxRunnable { diff --git a/src/main/java/com/avaje/ebean/TxScope.java b/src/main/java/com/avaje/ebean/TxScope.java index 0811f63b5..300e7b696 100644 --- a/src/main/java/com/avaje/ebean/TxScope.java +++ b/src/main/java/com/avaje/ebean/TxScope.java @@ -105,8 +105,7 @@ public final class TxScope { */ public String toString() { return "TxScope[" + type + "] readOnly[" + readOnly + "] isolation[" + isolation - + "] serverName[" + serverName - + "] rollbackFor[" + rollbackFor + "] noRollbackFor[" + noRollbackFor + "]"; + + "] serverName[" + serverName + "] rollbackFor[" + rollbackFor + "] noRollbackFor[" + noRollbackFor + "]"; } /** @@ -282,7 +281,7 @@ public final class TxScope { */ public TxScope setRollbackFor(Class rollbackThrowable) { if (rollbackFor == null) { - rollbackFor = new ArrayList>(2); + rollbackFor = new ArrayList<>(2); } rollbackFor.add(rollbackThrowable); return this; @@ -294,10 +293,10 @@ public final class TxScope { @SuppressWarnings("unchecked") public TxScope setRollbackFor(Class[] rollbackThrowables) { if (rollbackFor == null) { - rollbackFor = new ArrayList>(rollbackThrowables.length); + rollbackFor = new ArrayList<>(rollbackThrowables.length); } - for (int i = 0; i < rollbackThrowables.length; i++) { - rollbackFor.add((Class) rollbackThrowables[i]); + for (Class rollbackThrowable : rollbackThrowables) { + rollbackFor.add((Class) rollbackThrowable); } return this; } @@ -316,7 +315,7 @@ public final class TxScope { */ public TxScope setNoRollbackFor(Class noRollback) { if (noRollbackFor == null) { - noRollbackFor = new ArrayList>(2); + noRollbackFor = new ArrayList<>(2); } this.noRollbackFor.add(noRollback); return this; @@ -328,10 +327,10 @@ public final class TxScope { @SuppressWarnings("unchecked") public TxScope setNoRollbackFor(Class[] noRollbacks) { if (noRollbackFor == null) { - noRollbackFor = new ArrayList>(noRollbacks.length); + noRollbackFor = new ArrayList<>(noRollbacks.length); } - for (int i = 0; i < noRollbacks.length; i++) { - noRollbackFor.add((Class) noRollbacks[i]); + for (Class noRollback : noRollbacks) { + noRollbackFor.add((Class) noRollback); } return this; } diff --git a/src/main/java/com/avaje/ebean/TxType.java b/src/main/java/com/avaje/ebean/TxType.java index e1cb19511..08d724d24 100644 --- a/src/main/java/com/avaje/ebean/TxType.java +++ b/src/main/java/com/avaje/ebean/TxType.java @@ -8,7 +8,7 @@ package com.avaje.ebean; * {@link Ebean#execute(TxScope, TxCallable)} and * {@link Ebean#execute(TxScope, TxRunnable)}. *

- * + * * @see TxScope */ public enum TxType { diff --git a/src/main/java/com/avaje/ebean/Update.java b/src/main/java/com/avaje/ebean/Update.java index d58fb8575..cbebb6c2c 100644 --- a/src/main/java/com/avaje/ebean/Update.java +++ b/src/main/java/com/avaje/ebean/Update.java @@ -11,43 +11,43 @@ package com.avaje.ebean; *

* The following is an example of named updates on an entity bean. *

- * - *
+ * 
{@code
  *  ...
- * @NamedUpdates(value = {
- *   @NamedUpdate(
- *      name = "setTitle", 
- *      notifyCache = false, 
- *      update = "update topic set title = :title, postCount = :count where id = :id"),
- *  @NamedUpdate(
- *      name = "setPostCount", 
- *      notifyCache = false, 
- *      update = "update f_topic set post_count = :postCount where id = :id"),
- *  @NamedUpdate(
- *      name = "incrementPostCount", 
- *      notifyCache = false, 
- *      update = "update Topic set postCount = postCount + 1 where id = :id") 
- *      //update = "update f_topic set post_count = post_count + 1 where id = :id") 
+ * @NamedUpdates(value = {
+ *   @NamedUpdate(
+ *      name = "setTitle",
+ *      notifyCache = false,
+ *      update = "update topic set title = :title, postCount = :count where id = :id"),
+ *  @NamedUpdate(
+ *      name = "setPostCount",
+ *      notifyCache = false,
+ *      update = "update f_topic set post_count = :postCount where id = :id"),
+ *  @NamedUpdate(
+ *      name = "incrementPostCount",
+ *      notifyCache = false,
+ *      update = "update Topic set postCount = postCount + 1 where id = :id")
+ *      //update = "update f_topic set post_count = post_count + 1 where id = :id")
  *  })
- * @Entity
- * @Table(name = "f_topic")
+ * @Entity
+ * @Table(name = "f_topic")
  * public class Topic {
  *  ...
- * 
- * + * }
+ * *

* The following show code that would use a named update on the Topic entity * bean. *

- * - *
- * Update<Topic> update = Ebean.createUpdate(Topic.class, "incrementPostCount");
- * update.setParameter("id", 1);
+ * 

+ *

{@code
+ *
+ * Update update = Ebean.createUpdate(Topic.class, "incrementPostCount");
+ * update.setParameter("id", 1);
  * int rows = update.execute();
- * 
- * - * @param - * the type of entity beans inserted updated or deleted + * + * }
+ * + * @param the type of entity beans inserted updated or deleted */ public interface Update { @@ -73,9 +73,8 @@ public interface Update { * preparedStatement. If the timeout occurs an exception will be thrown - this * will be a SQLException wrapped up in a PersistenceException. *

- * - * @param secs - * the timeout in seconds. Zero implies unlimited. + * + * @param secs the timeout in seconds. Zero implies unlimited. */ Update setTimeout(int secs); @@ -92,21 +91,17 @@ public interface Update { *

* Set a value for each ? you have in the sql. *

- * - * @param position - * the index position of the parameter starting with 1. - * @param value - * the parameter value to bind. + * + * @param position the index position of the parameter starting with 1. + * @param value the parameter value to bind. */ Update set(int position, Object value); /** * Set and ordered bind parameter (same as bind). - * - * @param position - * the index position of the parameter starting with 1. - * @param value - * the parameter value to bind. + * + * @param position the index position of the parameter starting with 1. + * @param value the parameter value to bind. */ Update setParameter(int position, Object value); @@ -129,11 +124,9 @@ public interface Update { *

* A more succinct version of setParameter() to be consistent with Query. *

- * - * @param name - * the parameter name. - * @param value - * the parameter value. + * + * @param name the parameter name. + * @param value the parameter value. */ Update set(String name, Object value); @@ -148,11 +141,9 @@ public interface Update { *

* A more succinct version of setNullParameter(). *

- * - * @param name - * the parameter name. - * @param jdbcType - * the type of the property being bound. + * + * @param name the parameter name. + * @param jdbcType the type of the property being bound. */ Update setNull(String name, int jdbcType); @@ -166,4 +157,4 @@ public interface Update { */ String getGeneratedSql(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/UpdateQuery.java b/src/main/java/com/avaje/ebean/UpdateQuery.java index 3760d57f6..1245644cd 100644 --- a/src/main/java/com/avaje/ebean/UpdateQuery.java +++ b/src/main/java/com/avaje/ebean/UpdateQuery.java @@ -7,9 +7,9 @@ package com.avaje.ebean; * This UpdateQuery is more for the cases where we want to build the where expression of the update using the * {@link ExpressionList} "Criteria API" that is used with a normal ORM query. *

- * + *

*

Example: Simple update

- * + *

*

{@code
  *
  *  int rows = ebeanServer
@@ -26,18 +26,17 @@ package com.avaje.ebean;
  *   update o_customer set status=?, updtime=? where id > ?
  *
  * }
- * *

* Note that if the where() clause contains a join then the SQL update changes to use a * WHERE ID IN () form. *

- * + *

*

Example: Update with a JOIN

*

- * In this example the expression .eq("billingAddress.country", nz) requires a join - * to the address table. + * In this example the expression .eq("billingAddress.country", nz) requires a join + * to the address table. *

- * + *

*

{@code
  *
  *   int rows = ebeanServer
@@ -50,7 +49,7 @@ package com.avaje.ebean;
  *         .gt("id", 1000)
  *         .update();
  * }
- * + *

*

{@code sql
  *
  *   update o_customer set status=?, updtime=?
@@ -65,15 +64,13 @@ package com.avaje.ebean;
  * }
* * @param The type of entity bean being updated - * * @see SqlUpdate */ public interface UpdateQuery { /** * Set the value of a property. - * - * + *

*

{@code
    *
    *   int rows = ebeanServer
@@ -87,13 +84,13 @@ public interface UpdateQuery {
    * }
* * @param property The bean property to be set - * @param value The value to set the property to + * @param value The value to set the property to */ UpdateQuery set(String property, Object value); /** * Set the property to be null. - * + *

*

{@code
    *
    *   int rows = ebeanServer
@@ -110,12 +107,11 @@ public interface UpdateQuery {
   UpdateQuery setNull(String property);
 
   /**
-   *
    * Set using a property expression that does not need any bind values.
    * 

* The property expression typically contains database functions. *

- * + *

*

{@code
    *
    *   int rows = ebeanServer
@@ -148,7 +144,7 @@ public interface UpdateQuery {
    * }
* * @param propertyExpression A raw property expression - * @param values The values to bind with the property expression + * @param values The values to bind with the property expression */ UpdateQuery setRaw(String propertyExpression, Object... values); diff --git a/src/main/java/com/avaje/ebean/ValuePair.java b/src/main/java/com/avaje/ebean/ValuePair.java index e9a49eb75..8b3480449 100644 --- a/src/main/java/com/avaje/ebean/ValuePair.java +++ b/src/main/java/com/avaje/ebean/ValuePair.java @@ -29,7 +29,7 @@ public class ValuePair { public Object getNewValue() { return newValue; } - + /** * Return the old value. */ diff --git a/src/main/java/com/avaje/ebean/annotation/Aggregation.java b/src/main/java/com/avaje/ebean/annotation/Aggregation.java index 7fb6589cc..aeb4147c1 100644 --- a/src/main/java/com/avaje/ebean/annotation/Aggregation.java +++ b/src/main/java/com/avaje/ebean/annotation/Aggregation.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; * included in a query. To populate the aggregation property it must be * explicitly included in the select(). *

- * + *

*

Example:

*
{@code
  *
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
  * Long totalAmount;
  *
  * }
- * + *

*

Example query

*
{@code
  *
diff --git a/src/main/java/com/avaje/ebean/annotation/Cache.java b/src/main/java/com/avaje/ebean/annotation/Cache.java
index ea1a50f2a..59be62ef3 100644
--- a/src/main/java/com/avaje/ebean/annotation/Cache.java
+++ b/src/main/java/com/avaje/ebean/annotation/Cache.java
@@ -8,7 +8,7 @@ import java.lang.annotation.Target;
 /**
  * Specify the default cache use specific entity type.
  */
-@Target({ ElementType.TYPE })
+@Target({ElementType.TYPE})
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Cache {
 
diff --git a/src/main/java/com/avaje/ebean/annotation/CacheBeanTuning.java b/src/main/java/com/avaje/ebean/annotation/CacheBeanTuning.java
index 546f50d5f..b1a299f51 100644
--- a/src/main/java/com/avaje/ebean/annotation/CacheBeanTuning.java
+++ b/src/main/java/com/avaje/ebean/annotation/CacheBeanTuning.java
@@ -12,7 +12,7 @@ import java.lang.annotation.Target;
  * ElasticSearch, Hazelcast, Ignite etc.
  * 

*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface CacheBeanTuning { diff --git a/src/main/java/com/avaje/ebean/annotation/CacheQueryTuning.java b/src/main/java/com/avaje/ebean/annotation/CacheQueryTuning.java index 2fd1464e5..bf43ef9fc 100644 --- a/src/main/java/com/avaje/ebean/annotation/CacheQueryTuning.java +++ b/src/main/java/com/avaje/ebean/annotation/CacheQueryTuning.java @@ -11,7 +11,7 @@ import java.lang.annotation.Target; * If this is not specified then the system default settings are used. *

*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface CacheQueryTuning { diff --git a/src/main/java/com/avaje/ebean/annotation/CreatedTimestamp.java b/src/main/java/com/avaje/ebean/annotation/CreatedTimestamp.java index 49b5bc6a1..d53e62baf 100644 --- a/src/main/java/com/avaje/ebean/annotation/CreatedTimestamp.java +++ b/src/main/java/com/avaje/ebean/annotation/CreatedTimestamp.java @@ -22,7 +22,7 @@ import java.lang.annotation.Target; * timestamp value after the insert has occurred. You need to fetch the entity * back to get the inserted timestamp if you want to used it. *

- * + *

*

Example:

*
{@code
  *
@@ -31,7 +31,7 @@ import java.lang.annotation.Target;
  *
  * }
*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface CreatedTimestamp { diff --git a/src/main/java/com/avaje/ebean/annotation/DbArray.java b/src/main/java/com/avaje/ebean/annotation/DbArray.java index 5c81651d5..8d3fd5d24 100644 --- a/src/main/java/com/avaje/ebean/annotation/DbArray.java +++ b/src/main/java/com/avaje/ebean/annotation/DbArray.java @@ -11,7 +11,7 @@ import java.lang.annotation.Target; * If the target database does not support ARRAY type (so not Postgres) * then the collection will be stored in JSON format into a VARCHAR column. *

- * + *

*

Example:

*
{@code
  *
diff --git a/src/main/java/com/avaje/ebean/annotation/DbHstore.java b/src/main/java/com/avaje/ebean/annotation/DbHstore.java
index 9ffd29760..87ede7183 100644
--- a/src/main/java/com/avaje/ebean/annotation/DbHstore.java
+++ b/src/main/java/com/avaje/ebean/annotation/DbHstore.java
@@ -10,7 +10,7 @@ import java.lang.annotation.Target;
  * 

* The Map property should have keys and values of type String. *

- * + *

*

Example:

*
{@code
  *
@@ -27,4 +27,4 @@ public @interface DbHstore {
    * For VARCHAR storage specify the column length (defaults to 1000).
    */
   int length() default 0;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/avaje/ebean/annotation/DbJson.java b/src/main/java/com/avaje/ebean/annotation/DbJson.java
index d5bf2b059..07cf1564e 100644
--- a/src/main/java/com/avaje/ebean/annotation/DbJson.java
+++ b/src/main/java/com/avaje/ebean/annotation/DbJson.java
@@ -18,7 +18,7 @@ import java.lang.annotation.Target;
  * Map content;
  *
  * }
- * + *

*

Example with JSONB storage

*
{@code
  *
@@ -41,4 +41,4 @@ public @interface DbJson {
    * For VARCHAR storage specify the column length (defaults to 3000).
    */
   int length() default 0;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/avaje/ebean/annotation/DbJsonB.java b/src/main/java/com/avaje/ebean/annotation/DbJsonB.java
index ebfaf9270..418294006 100644
--- a/src/main/java/com/avaje/ebean/annotation/DbJsonB.java
+++ b/src/main/java/com/avaje/ebean/annotation/DbJsonB.java
@@ -11,9 +11,9 @@ import java.lang.annotation.Target;
  * The content will be stored on Postgres using it's JSONB type and as Clob for other databases.
  * 

*

- * This is equivalent to using @DbJson(storage = DbJsonType.JSONB) + * This is equivalent to using @DbJson(storage = DbJsonType.JSONB) *

- * + *

*

Example:

*
{@code
  *
@@ -22,7 +22,7 @@ import java.lang.annotation.Target;
  * Map content;
  *
  * }
- * + *

*

Equivalent to:

*
{@code
  *
@@ -40,4 +40,4 @@ public @interface DbJsonB {
    * For VARCHAR storage specify the column length.
    */
   int length() default 0;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/avaje/ebean/annotation/DocEmbedded.java b/src/main/java/com/avaje/ebean/annotation/DocEmbedded.java
index f0e258287..5cfd92ce7 100644
--- a/src/main/java/com/avaje/ebean/annotation/DocEmbedded.java
+++ b/src/main/java/com/avaje/ebean/annotation/DocEmbedded.java
@@ -7,7 +7,6 @@ import java.lang.annotation.Target;
 
 /**
  * Specify the property is included in the parent document store index.
- *
  * 
{@code
  *
  *
@@ -25,7 +24,7 @@ import java.lang.annotation.Target;
  *
  * }
*/ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface DocEmbedded { diff --git a/src/main/java/com/avaje/ebean/annotation/DocMapping.java b/src/main/java/com/avaje/ebean/annotation/DocMapping.java index b95a1ec74..10c1fc857 100644 --- a/src/main/java/com/avaje/ebean/annotation/DocMapping.java +++ b/src/main/java/com/avaje/ebean/annotation/DocMapping.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * Specify the entity type maps to a document store (like ElasticSearch). */ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface DocMapping { diff --git a/src/main/java/com/avaje/ebean/annotation/DocProperty.java b/src/main/java/com/avaje/ebean/annotation/DocProperty.java index 4cc5ad262..ee4aaa21b 100644 --- a/src/main/java/com/avaje/ebean/annotation/DocProperty.java +++ b/src/main/java/com/avaje/ebean/annotation/DocProperty.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * Specify the entity type maps to a document store (like ElasticSearch). */ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface DocProperty { diff --git a/src/main/java/com/avaje/ebean/annotation/DocSortable.java b/src/main/java/com/avaje/ebean/annotation/DocSortable.java index f0b87b450..ba554c1c5 100644 --- a/src/main/java/com/avaje/ebean/annotation/DocSortable.java +++ b/src/main/java/com/avaje/ebean/annotation/DocSortable.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; * For example, customer name and product name are good candidates for marking with @DocSortable. *

*/ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface DocSortable { diff --git a/src/main/java/com/avaje/ebean/annotation/DocStore.java b/src/main/java/com/avaje/ebean/annotation/DocStore.java index be116b799..808c35977 100644 --- a/src/main/java/com/avaje/ebean/annotation/DocStore.java +++ b/src/main/java/com/avaje/ebean/annotation/DocStore.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * Specify the entity type maps to a document store (like ElasticSearch). */ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface DocStore { @@ -73,7 +73,6 @@ public @interface DocStore { * Note that typically DocStoreEmbedded is used on @ManyToOne and @OneToMany * properties to indicate what part of the nested document should be included. *

- * *

Example:

*
{@code
    *
diff --git a/src/main/java/com/avaje/ebean/annotation/DocStoreMode.java b/src/main/java/com/avaje/ebean/annotation/DocStoreMode.java
index b4805ee75..03297dbc6 100644
--- a/src/main/java/com/avaje/ebean/annotation/DocStoreMode.java
+++ b/src/main/java/com/avaje/ebean/annotation/DocStoreMode.java
@@ -23,9 +23,9 @@ public enum DocStoreMode {
   /**
    * Ignore the event and not update the document store.
    * 

- * This can be used on a index or for a transaction where you want to have more - * manual programmatic control over the updating of the document store. Say you want to - * IGNORE on a particular transaction and instead manually queue a bulk update. + * This can be used on a index or for a transaction where you want to have more + * manual programmatic control over the updating of the document store. Say you want to + * IGNORE on a particular transaction and instead manually queue a bulk update. *

*/ IGNORE, diff --git a/src/main/java/com/avaje/ebean/annotation/EmbeddedColumns.java b/src/main/java/com/avaje/ebean/annotation/EmbeddedColumns.java index 5a68edbac..b63ecfebf 100644 --- a/src/main/java/com/avaje/ebean/annotation/EmbeddedColumns.java +++ b/src/main/java/com/avaje/ebean/annotation/EmbeddedColumns.java @@ -12,7 +12,7 @@ import java.lang.annotation.Target; * standard JPA. *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface EmbeddedColumns { diff --git a/src/main/java/com/avaje/ebean/annotation/Encrypted.java b/src/main/java/com/avaje/ebean/annotation/Encrypted.java index a803ddc0a..25c1697c0 100644 --- a/src/main/java/com/avaje/ebean/annotation/Encrypted.java +++ b/src/main/java/com/avaje/ebean/annotation/Encrypted.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * Specify that the property is stored in encrypted form. */ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface Encrypted { diff --git a/src/main/java/com/avaje/ebean/annotation/EnumValue.java b/src/main/java/com/avaje/ebean/annotation/EnumValue.java index 8dce61fdc..d34294327 100644 --- a/src/main/java/com/avaje/ebean/annotation/EnumValue.java +++ b/src/main/java/com/avaje/ebean/annotation/EnumValue.java @@ -7,21 +7,20 @@ import java.lang.annotation.Target; /** * Enables you to specify a value to use to persist for an enum value. - * *
{@code
  *
  * public enum Status {
  *
  *   @EnumValue("N")
  *   NEW,
- * 
+ *
  *   @EnumValue("A")
  *   ACTIVE,
- * 
+ *
  *   @EnumValue("I")
  *   INACTIVE,
  * }
- * 
+ *
  * }
*

* This is an alternative to using the JPA standard approach or Ebean's @@ -33,7 +32,7 @@ import java.lang.annotation.Target; * and fetched as strings. *

*/ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface EnumValue { diff --git a/src/main/java/com/avaje/ebean/annotation/Formula.java b/src/main/java/com/avaje/ebean/annotation/Formula.java index e0b9cb682..f53de86ee 100644 --- a/src/main/java/com/avaje/ebean/annotation/Formula.java +++ b/src/main/java/com/avaje/ebean/annotation/Formula.java @@ -1,14 +1,14 @@ package com.avaje.ebean.annotation; +import com.avaje.ebean.Query; +import com.avaje.ebean.config.dbplatform.DatabasePlatform; + import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.avaje.ebean.Query; -import com.avaje.ebean.config.dbplatform.DatabasePlatform; - /** * Assign to a property to be based on a SQL formula. *

@@ -26,28 +26,27 @@ import com.avaje.ebean.config.dbplatform.DatabasePlatform; * You may want to do this if the Formula is relatively expensive and only want * it included in the query when you explicitly state it. *

- * - *
- * // On the Order "master" bean
+ * 

+ *

{@code
+ * // On the Order "master" bean
  * // ... a formula using the Order details
  * // ... sum(order_qty*unit_price)
- * @Transient
- * @Formula(select = "_b${ta}.total_amount", join = "join (select order_id, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) as _b${ta} on _b${ta}.order_id = ${ta}.id")
+ * @Transient
+ * @Formula(select = "_b${ta}.total_amount", join = "join (select order_id, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) as _b${ta} on _b${ta}.order_id = ${ta}.id")
  * Double totalAmount;
- * 
- * 
+ * + * }
*

* As the totalAmount formula is also Transient it is not included by default in * queries - it needs to be explicitly included. *

- * *
{@code
  *
  * // find by Id
  * Order o1 = Ebean.find(Order.class)
  *     .select("id, totalAmount")
  *     .setId(1).findUnique();
- * 
+ *
  * // find list ... using totalAmount in the where clause
  * List list = Ebean.find(Order.class)
  *     .select("id, totalAmount")
@@ -55,7 +54,7 @@ import com.avaje.ebean.config.dbplatform.DatabasePlatform;
  *     .eq("status", Order.Status.NEW)
  *     .gt("totalAmount", 10)
  *     .findList();
- * 
+ *
  * // as a join from customer
  * List l0 = Ebean.find(Customer.class)
  *     .select("id, name")
@@ -64,10 +63,10 @@ import com.avaje.ebean.config.dbplatform.DatabasePlatform;
  *     .gt("id", 0)
  *     .gt("orders.totalAmount", 10)
  *     .findList();
- * 
+ *
  * }
*/ -@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(Formula.List.class) public @interface Formula { @@ -87,7 +86,6 @@ public @interface Formula { *

* The join string should start with either "left join" or "join". *

- * *

* You will almost certainly use the "${ta}" as a place holder for the table * alias of the table you are joining back to (the "base table" of the entity @@ -97,7 +95,7 @@ public @interface Formula { * The example below is used to support a total count of topics created by a * user. *

- * + *

*

{@code
    *
    * join (select user_id, count(*) as topic_count from f_topic group by user_id) as _tc on _tc.user_id = ${ta}.id
diff --git a/src/main/java/com/avaje/ebean/annotation/History.java b/src/main/java/com/avaje/ebean/annotation/History.java
index 36888086d..9548b3cf1 100644
--- a/src/main/java/com/avaje/ebean/annotation/History.java
+++ b/src/main/java/com/avaje/ebean/annotation/History.java
@@ -12,7 +12,7 @@ import java.lang.annotation.Target;
  * typically automatically populated via database triggers.
  * 

*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface History { diff --git a/src/main/java/com/avaje/ebean/annotation/HistoryExclude.java b/src/main/java/com/avaje/ebean/annotation/HistoryExclude.java index a41dfe1d9..bae53aa35 100644 --- a/src/main/java/com/avaje/ebean/annotation/HistoryExclude.java +++ b/src/main/java/com/avaje/ebean/annotation/HistoryExclude.java @@ -18,7 +18,7 @@ import java.lang.annotation.Target; * support. *

*/ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface HistoryExclude { diff --git a/src/main/java/com/avaje/ebean/annotation/Index.java b/src/main/java/com/avaje/ebean/annotation/Index.java index ae82a8802..426320f5f 100644 --- a/src/main/java/com/avaje/ebean/annotation/Index.java +++ b/src/main/java/com/avaje/ebean/annotation/Index.java @@ -29,7 +29,7 @@ public @interface Index { /** * When placed on the class (rather than field) you can specify the columns * to include in the index in order. - * + *

* Wnen placed on a field, and columnNames are specified, the field-column has to be included. * You can use "${fa}" for alias */ diff --git a/src/main/java/com/avaje/ebean/annotation/Indices.java b/src/main/java/com/avaje/ebean/annotation/Indices.java index 0886482ed..0e74559f7 100644 --- a/src/main/java/com/avaje/ebean/annotation/Indices.java +++ b/src/main/java/com/avaje/ebean/annotation/Indices.java @@ -4,9 +4,10 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + /** * An annotation for declaring multiple indices at class or field level. - * + * * @author Roland Praml, FOCONIS AG */ @Target({ElementType.TYPE, ElementType.FIELD}) diff --git a/src/main/java/com/avaje/ebean/annotation/JsonIgnore.java b/src/main/java/com/avaje/ebean/annotation/JsonIgnore.java index 79635ddc1..822882a0c 100644 --- a/src/main/java/com/avaje/ebean/annotation/JsonIgnore.java +++ b/src/main/java/com/avaje/ebean/annotation/JsonIgnore.java @@ -8,8 +8,8 @@ import java.lang.annotation.Target; /** * Similar to Jackson JsonIgnore but provides the option to just ignore serialize or deserialize. *

- * This provides the same features as Expose but from the opposite perspective which is probably - * more common and more familiar to Jackson users. + * This provides the same features as Expose but from the opposite perspective which is probably + * more common and more familiar to Jackson users. *

*/ @Retention(RetentionPolicy.RUNTIME) @@ -29,4 +29,4 @@ public @interface JsonIgnore { * Defaults to {@code false}. */ boolean deserialize() default false; -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/annotation/PrivateOwned.java b/src/main/java/com/avaje/ebean/annotation/PrivateOwned.java index 684f5a416..a7d58f978 100644 --- a/src/main/java/com/avaje/ebean/annotation/PrivateOwned.java +++ b/src/main/java/com/avaje/ebean/annotation/PrivateOwned.java @@ -18,7 +18,7 @@ import java.lang.annotation.Target; * in that they are no longer associated/linked to their parent bean. *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface PrivateOwned { diff --git a/src/main/java/com/avaje/ebean/annotation/Sql.java b/src/main/java/com/avaje/ebean/annotation/Sql.java index 223db95c5..a37c70d96 100644 --- a/src/main/java/com/avaje/ebean/annotation/Sql.java +++ b/src/main/java/com/avaje/ebean/annotation/Sql.java @@ -11,7 +11,7 @@ import java.lang.annotation.Target; * This means the entity bean has no base table specified (via @Table). *

*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Sql { diff --git a/src/main/java/com/avaje/ebean/annotation/Transactional.java b/src/main/java/com/avaje/ebean/annotation/Transactional.java index 5de7f8b6c..db998ad94 100644 --- a/src/main/java/com/avaje/ebean/annotation/Transactional.java +++ b/src/main/java/com/avaje/ebean/annotation/Transactional.java @@ -1,14 +1,14 @@ package com.avaje.ebean.annotation; +import com.avaje.ebean.TxIsolation; +import com.avaje.ebean.TxType; +import com.avaje.ebean.config.PersistBatch; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.avaje.ebean.TxIsolation; -import com.avaje.ebean.TxType; -import com.avaje.ebean.config.PersistBatch; - /** * Specify transaction scoping for a method. *

@@ -33,22 +33,22 @@ import com.avaje.ebean.config.PersistBatch; * to set the default behaviour to rollback on any exception and optionally * change the setting to be consistent with EJB/Spring if people wish to do so. *

- * + *

*

{@code
  *
  *  // a normal class
  *  public class MySimpleUserService {
- * 
+ *
  *    // this method is transactional automatically handling
  *    // transaction begin, commit and rollback etc
  *    @Transactional
  *    public void runInTrans() throws IOException {
- * 
+ *
  *      // tasks performed within the transaction
  *      ...
  *      // find some objects
  *      Customer cust = ebeanServer.find(Customer.class, 42);
- *    
+ *
  *      Order order = ...;
  *      ...
  *      // save some objects
@@ -58,7 +58,7 @@ import com.avaje.ebean.config.PersistBatch;
  *
  * }
*/ -@Target({ ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Transactional { diff --git a/src/main/java/com/avaje/ebean/annotation/UpdateMode.java b/src/main/java/com/avaje/ebean/annotation/UpdateMode.java index f051262a8..0353737bc 100644 --- a/src/main/java/com/avaje/ebean/annotation/UpdateMode.java +++ b/src/main/java/com/avaje/ebean/annotation/UpdateMode.java @@ -14,13 +14,13 @@ import java.lang.annotation.Target; *

* Note that the default can be set via ebean.properties. *

- * + *

*

  * ## Set to update all loaded properties
  * ebean.updateChangesOnly=false
  * 
*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface UpdateMode { diff --git a/src/main/java/com/avaje/ebean/annotation/UpdatedTimestamp.java b/src/main/java/com/avaje/ebean/annotation/UpdatedTimestamp.java index b93a5ab37..8a181369e 100644 --- a/src/main/java/com/avaje/ebean/annotation/UpdatedTimestamp.java +++ b/src/main/java/com/avaje/ebean/annotation/UpdatedTimestamp.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; * towards a better naming convention (WhenCreated, WhenModified). *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface UpdatedTimestamp { diff --git a/src/main/java/com/avaje/ebean/annotation/WhenCreated.java b/src/main/java/com/avaje/ebean/annotation/WhenCreated.java index 0d20fdc7a..6779254d1 100644 --- a/src/main/java/com/avaje/ebean/annotation/WhenCreated.java +++ b/src/main/java/com/avaje/ebean/annotation/WhenCreated.java @@ -22,7 +22,7 @@ import java.lang.annotation.Target; * timestamp value after the insert has occurred. You need to fetch the entity * back to get the inserted timestamp if you want to used it. *

- * + *

*

Example:

*
{@code
  *
@@ -31,7 +31,7 @@ import java.lang.annotation.Target;
  *
  * }
*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface WhenCreated { diff --git a/src/main/java/com/avaje/ebean/annotation/WhenModified.java b/src/main/java/com/avaje/ebean/annotation/WhenModified.java index 1dbfd674e..3e9838816 100644 --- a/src/main/java/com/avaje/ebean/annotation/WhenModified.java +++ b/src/main/java/com/avaje/ebean/annotation/WhenModified.java @@ -12,7 +12,7 @@ import java.lang.annotation.Target; * towards a better naming convention (WhenCreated, WhenModified). *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface WhenModified { diff --git a/src/main/java/com/avaje/ebean/annotation/Where.java b/src/main/java/com/avaje/ebean/annotation/Where.java index 2c9ccf03a..b73e81100 100644 --- a/src/main/java/com/avaje/ebean/annotation/Where.java +++ b/src/main/java/com/avaje/ebean/annotation/Where.java @@ -11,37 +11,33 @@ import com.avaje.ebean.config.dbplatform.DatabasePlatform; /** * Add an Literal to add to the where clause when a many property (List, Set or * Map) is loaded or refreshed. - * *
{@code
  *
  * // on a OneToMany property...
- * 
+ *
  * @OneToMany
  * @Where(clause = "deleted='y'")
  * List topics;
  *
  * }
- * *

* Note that you can include "${ta}" as a place holder for the table alias if * you need to include the table alias in the clause. *

- * *
{@code
  * // ... including the ${ta} table alias placeholder...
- * 
+ *
  * @OneToMany
  * @Where(clause = "${ta}.deleted='y'")
  * List topics;
  *
  * }
- * *

* This will be added to the where clause when lazy loading the OneToMany * property or when there is a join to that OneToMany property. *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(Where.List.class) public @interface Where { diff --git a/src/main/java/com/avaje/ebean/annotation/WhoCreated.java b/src/main/java/com/avaje/ebean/annotation/WhoCreated.java index c9dcfdfae..8bb199834 100644 --- a/src/main/java/com/avaje/ebean/annotation/WhoCreated.java +++ b/src/main/java/com/avaje/ebean/annotation/WhoCreated.java @@ -12,8 +12,7 @@ import java.lang.annotation.Target; * To use this annotation you need to implement CurrentUserProvider. * The type of the bean property should match the type returned by * CurrentUserProvider. - *

- + *

*

Example:

*
{@code
  *
@@ -22,7 +21,7 @@ import java.lang.annotation.Target;
  *
  * }
*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface WhoCreated { diff --git a/src/main/java/com/avaje/ebean/annotation/WhoModified.java b/src/main/java/com/avaje/ebean/annotation/WhoModified.java index 1ef57e298..5bd2c9de0 100644 --- a/src/main/java/com/avaje/ebean/annotation/WhoModified.java +++ b/src/main/java/com/avaje/ebean/annotation/WhoModified.java @@ -13,7 +13,6 @@ import java.lang.annotation.Target; * The type of the bean property should match the type returned by * CurrentUserProvider. *

- * *

Example:

*
{@code
  *
diff --git a/src/main/java/com/avaje/ebean/annotation/package.html b/src/main/java/com/avaje/ebean/annotation/package.html
index c39eed7aa..a3cb62253 100644
--- a/src/main/java/com/avaje/ebean/annotation/package.html
+++ b/src/main/java/com/avaje/ebean/annotation/package.html
@@ -1,14 +1,14 @@
 
 
-	
-	Extra deployment annotations
+  
+  Extra deployment annotations
 
 
 Extra deployment annotations
 
 

-Extra deployment annotations for entity beans. + Extra deployment annotations for entity beans.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/bean/BeanCollection.java b/src/main/java/com/avaje/ebean/bean/BeanCollection.java index 59470843e..aec02a5d3 100644 --- a/src/main/java/com/avaje/ebean/bean/BeanCollection.java +++ b/src/main/java/com/avaje/ebean/bean/BeanCollection.java @@ -1,11 +1,11 @@ package com.avaje.ebean.bean; +import com.avaje.ebean.ExpressionList; + import java.io.Serializable; import java.util.Collection; import java.util.Set; -import com.avaje.ebean.ExpressionList; - /** * Lazy loading capable Maps, Lists and Sets. *

@@ -23,11 +23,17 @@ import com.avaje.ebean.ExpressionList; public interface BeanCollection extends Serializable { enum ModifyListenMode { - /** The common mode */ + /** + * The common mode + */ NONE, - /** Mode used for PrivateOwned */ + /** + * Mode used for PrivateOwned + */ REMOVALS, - /** Mode used for ManyToMany relationships */ + /** + * Mode used for ManyToMany relationships + */ ALL } diff --git a/src/main/java/com/avaje/ebean/bean/CallStack.java b/src/main/java/com/avaje/ebean/bean/CallStack.java index 3d0f61f86..54f625e83 100644 --- a/src/main/java/com/avaje/ebean/bean/CallStack.java +++ b/src/main/java/com/avaje/ebean/bean/CallStack.java @@ -34,12 +34,12 @@ public final class CallStack implements Serializable { public int hashCode() { int hc = 0; - for (int i = 0; i < callStack.length; i++) { - hc = 31 * hc + callStack[i].hashCode(); + for (StackTraceElement aCallStack : callStack) { + hc = 31 * hc + aCallStack.hashCode(); } return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -88,14 +88,14 @@ public final class CallStack implements Serializable { */ public String description(String newLine) { StringBuilder sb = new StringBuilder(400); - for (int i = 0; i < callStack.length; i++) { - sb.append(callStack[i].toString()).append(newLine); + for (StackTraceElement aCallStack : callStack) { + sb.append(aCallStack.toString()).append(newLine); } return sb.toString(); } public String getOriginKey(int queryHash) { - return enc(queryHash)+ "." + zeroHash + "." + pathHash; + return enc(queryHash) + "." + zeroHash + "." + pathHash; } private static final int radix = 1 << 6; @@ -116,10 +116,10 @@ public final class CallStack implements Serializable { } private static final char intToBase64[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' }; } diff --git a/src/main/java/com/avaje/ebean/bean/EntityBean.java b/src/main/java/com/avaje/ebean/bean/EntityBean.java index f4b0c12d1..4fd4f226a 100644 --- a/src/main/java/com/avaje/ebean/bean/EntityBean.java +++ b/src/main/java/com/avaje/ebean/bean/EntityBean.java @@ -15,9 +15,9 @@ import java.io.Serializable; public interface EntityBean extends Serializable { String[] _ebean_getPropertyNames(); - + String _ebean_getPropertyName(int pos); - + /** * Return the enhancement marker value. *

diff --git a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java index 22d68e0e4..2ff325daa 100644 --- a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java +++ b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java @@ -30,7 +30,7 @@ public final class EntityBeanIntercept implements Serializable { private static final int STATE_NEW = 0; private static final int STATE_REFERENCE = 1; private static final int STATE_LOADED = 2; - + private transient NodeUsageCollector nodeUsageCollector; private transient PropertyChangeSupport pcs; @@ -55,11 +55,11 @@ public final class EntityBeanIntercept implements Serializable { * One of NEW, REF, UPD. */ private int state; - + private boolean readOnly; - + private boolean dirty; - + /** * Flag set to disable lazy loading - typically for SQL "report" type entity beans. */ @@ -74,14 +74,14 @@ public final class EntityBeanIntercept implements Serializable { * Used when a bean is partially filled. */ private final boolean[] loadedProps; - + private boolean fullyLoadedBean; /** * Set of changed properties. */ private boolean[] changedProps; - + /** * Flags indicating if a property is a dirty embedded bean. Used to distingush * between an embedded bean being completely overwritten and one of its @@ -180,7 +180,7 @@ public final class EntityBeanIntercept implements Serializable { public Object getEmbeddedOwner() { return embeddedOwner; } - + /** * Return the property index (for the parent) of this embedded bean. */ @@ -240,8 +240,8 @@ public final class EntityBeanIntercept implements Serializable { * Check each property to see if the bean is partially loaded. */ public boolean isPartial() { - for (int i = 0; i < loadedProps.length; i++) { - if (!loadedProps[i]) { + for (boolean loadedProp : loadedProps) { + if (!loadedProp) { return true; } } @@ -263,7 +263,7 @@ public final class EntityBeanIntercept implements Serializable { this.dirty = true; setEmbeddedPropertyDirty(embeddedProperty); } - + public void setDirty(boolean dirty) { this.dirty = dirty; } @@ -290,12 +290,12 @@ public final class EntityBeanIntercept implements Serializable { if (i == idIndex) { if (!loadedProps[i]) return false; } else if (loadedProps[i]) { - return false; + return false; } } return true; } - + /** * Return true if the entity is a reference. */ @@ -311,8 +311,8 @@ public final class EntityBeanIntercept implements Serializable { if (idPos > -1) { // For cases where properties are set on constructor // set every non Id property to unloaded (for lazy loading) - for (int i=0; i< loadedProps.length; i++) { - if (i != idPos) { + for (int i = 0; i < loadedProps.length; i++) { + if (i != idPos) { loadedProps[i] = false; } } @@ -448,7 +448,7 @@ public final class EntityBeanIntercept implements Serializable { } return origValues[propertyIndex]; } - + /** * Finds the index position of a given property. Returns -1 if the property * can not be found. @@ -462,7 +462,7 @@ public final class EntityBeanIntercept implements Serializable { } return -1; } - + /** * Return the property name for the given property. */ @@ -472,7 +472,7 @@ public final class EntityBeanIntercept implements Serializable { } return owner._ebean_getPropertyName(propertyIndex); } - + /** * Return the number of properties.s */ @@ -486,7 +486,7 @@ public final class EntityBeanIntercept implements Serializable { public void setPropertyLoaded(String propertyName, boolean loaded) { int position = findProperty(propertyName); if (position == -1) { - throw new IllegalArgumentException("Property "+propertyName+" not found"); + throw new IllegalArgumentException("Property " + propertyName + " not found"); } loadedProps[position] = loaded; } @@ -498,7 +498,7 @@ public final class EntityBeanIntercept implements Serializable { public void setPropertyUnloaded(int propertyIndex) { loadedProps[propertyIndex] = false; } - + /** * Set the property to be loaded. */ @@ -525,8 +525,8 @@ public final class EntityBeanIntercept implements Serializable { * embedded properties is dirty. */ public boolean isDirtyProperty(int propertyIndex) { - return (changedProps != null && changedProps[propertyIndex] - || embeddedDirty != null && embeddedDirty[propertyIndex]); + return (changedProps != null && changedProps[propertyIndex] + || embeddedDirty != null && embeddedDirty[propertyIndex]); } /** @@ -536,7 +536,7 @@ public final class EntityBeanIntercept implements Serializable { setChangedProperty(propertyIndex); setDirty(true); } - + public void setChangedProperty(int propertyIndex) { if (changedProps == null) { changedProps = new boolean[owner._ebean_getPropertyNames().length]; @@ -553,7 +553,7 @@ public final class EntityBeanIntercept implements Serializable { } embeddedDirty[propertyIndex] = true; } - + private void setOriginalValue(int propertyIndex, Object value) { if (origValues == null) { origValues = new Object[owner._ebean_getPropertyNames().length]; @@ -567,19 +567,19 @@ public final class EntityBeanIntercept implements Serializable { * For forced update on a 'New' bean set all the loaded properties to changed. */ public void setNewBeanForUpdate() { - + if (changedProps == null) { changedProps = new boolean[owner._ebean_getPropertyNames().length]; } - - for (int i=0; i< loadedProps.length; i++) { + + for (int i = 0; i < loadedProps.length; i++) { if (loadedProps[i]) { - changedProps[i] = true; + changedProps[i] = true; } } setDirty(true); } - + /** * Return the set of property names for a partially loaded bean. */ @@ -587,8 +587,8 @@ public final class EntityBeanIntercept implements Serializable { if (fullyLoadedBean) { return null; } - Set props = new LinkedHashSet(); - for (int i=0; i props = new LinkedHashSet<>(); + for (int i = 0; i < loadedProps.length; i++) { if (loadedProps[i]) { props.add(getProperty(i)); } @@ -617,11 +617,11 @@ public final class EntityBeanIntercept implements Serializable { * Return the set of dirty properties. */ public Set getDirtyPropertyNames() { - Set props = new LinkedHashSet(); + Set props = new LinkedHashSet<>(); addDirtyPropertyNames(props, null); return props; } - + /** * Recursively add dirty properties. */ @@ -634,8 +634,8 @@ public final class EntityBeanIntercept implements Serializable { props.add(propName); } else if (embeddedDirty != null && embeddedDirty[i]) { // an embedded property has been changed - recurse - EntityBean embeddedBean = (EntityBean)owner._ebean_getField(i); - embeddedBean._ebean_getIntercept().addDirtyPropertyNames(props, getProperty(i)+"."); + EntityBean embeddedBean = (EntityBean) owner._ebean_getField(i); + embeddedBean._ebean_getIntercept().addDirtyPropertyNames(props, getProperty(i) + "."); } } } @@ -665,16 +665,16 @@ public final class EntityBeanIntercept implements Serializable { /** * Return a map of dirty properties with their new and old values. */ - public Map getDirtyValues() { - Map dirtyValues = new LinkedHashMap(); + public Map getDirtyValues() { + Map dirtyValues = new LinkedHashMap<>(); addDirtyPropertyValues(dirtyValues, null); return dirtyValues; } - + /** * Recursively add dirty properties. */ - public void addDirtyPropertyValues(Map dirtyValues, String prefix) { + public void addDirtyPropertyValues(Map dirtyValues, String prefix) { int len = getPropertyLength(); for (int i = 0; i < len; i++) { if (changedProps != null && changedProps[i]) { @@ -684,22 +684,22 @@ public final class EntityBeanIntercept implements Serializable { Object oldVal = getOrigValue(i); dirtyValues.put(propName, new ValuePair(newVal, oldVal)); - + } else if (embeddedDirty != null && embeddedDirty[i]) { // an embedded property has been changed - recurse - EntityBean embeddedBean = (EntityBean)owner._ebean_getField(i); + EntityBean embeddedBean = (EntityBean) owner._ebean_getField(i); embeddedBean._ebean_getIntercept().addDirtyPropertyValues(dirtyValues, getProperty(i) + "."); } } } - + /** * Return a dirty property hash taking into account embedded beans. */ public int getDirtyPropertyHash() { return addDirtyPropertyHash(37); } - + /** * Add and return a dirty property hash recursing into embedded beans. */ @@ -708,10 +708,10 @@ public final class EntityBeanIntercept implements Serializable { for (int i = 0; i < len; i++) { if (changedProps != null && changedProps[i]) { // the property has been changed on this bean - hash = hash * 31 + (i+1); + hash = hash * 31 + (i + 1); } else if (embeddedDirty != null && embeddedDirty[i]) { // an embedded property has been changed - recurse - EntityBean embeddedBean = (EntityBean)owner._ebean_getField(i); + EntityBean embeddedBean = (EntityBean) owner._ebean_getField(i); hash = hash * 31 + embeddedBean._ebean_getIntercept().addDirtyPropertyHash(hash); } } @@ -726,7 +726,7 @@ public final class EntityBeanIntercept implements Serializable { int len = getPropertyLength(); for (int i = 0; i < len; i++) { if (isLoadedProperty(i)) { - hash = hash * 31 + (i+1); + hash = hash * 31 + (i + 1); } } return hash; @@ -749,7 +749,7 @@ public final class EntityBeanIntercept implements Serializable { public int getLazyLoadPropertyIndex() { return lazyLoadProperty; } - + /** * Return the property that triggered the lazy load. */ @@ -821,7 +821,7 @@ public final class EntityBeanIntercept implements Serializable { /** * Helper method to check if two objects are equal. */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) protected boolean areEqual(Object obj1, Object obj2) { if (obj1 == null) { return (obj2 == null); @@ -849,7 +849,7 @@ public final class EntityBeanIntercept implements Serializable { } return obj1.equals(obj2); } - + /** * Called when a BeanCollection is initialised automatically. */ @@ -920,7 +920,7 @@ public final class EntityBeanIntercept implements Serializable { if (readOnly) { throw new IllegalStateException("This bean is readOnly"); } - + setLoadedProperty(propertyIndex); // Bean itself not considered dirty when many changed @@ -930,7 +930,7 @@ public final class EntityBeanIntercept implements Serializable { return null; } } - + private void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue) { if (readOnly) { @@ -941,7 +941,7 @@ public final class EntityBeanIntercept implements Serializable { if (setDirtyState) { setOriginalValue(propertyIndex, origValue); if (!dirty) { - dirty = true; + dirty = true; if (embeddedOwner != null) { // Cascade dirty state from Embedded bean to parent bean embeddedOwner._ebean_getIntercept().setEmbeddedDirty(embeddedOwnerIndex); @@ -952,7 +952,7 @@ public final class EntityBeanIntercept implements Serializable { } } } - + /** * Check to see if the values are not equal. If they are not equal then create * the old values for use with ConcurrencyMode.ALL. @@ -962,15 +962,15 @@ public final class EntityBeanIntercept implements Serializable { if (state == STATE_NEW) { setLoadedProperty(propertyIndex); } else if (!areEqual(oldValue, newValue)) { - setChangedPropertyValue(propertyIndex, intercept, oldValue); + setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } - - return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); + + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } - - + + /** * Check for primitive boolean. */ @@ -1007,13 +1007,13 @@ public final class EntityBeanIntercept implements Serializable { public PropertyChangeEvent preSetter(boolean intercept, int propertyIndex, long oldValue, long newValue) { if (state == STATE_NEW) { - setLoadedProperty(propertyIndex); + setLoadedProperty(propertyIndex); } else if (oldValue != newValue) { setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } - + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } @@ -1025,7 +1025,7 @@ public final class EntityBeanIntercept implements Serializable { if (state == STATE_NEW) { setLoadedProperty(propertyIndex); } else if (oldValue != newValue) { - setChangedPropertyValue(propertyIndex, intercept, oldValue); + setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } @@ -1044,7 +1044,7 @@ public final class EntityBeanIntercept implements Serializable { } else { return null; } - return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } /** @@ -1104,7 +1104,7 @@ public final class EntityBeanIntercept implements Serializable { } else { return null; } - return (pcs == null) ? null: new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } /** diff --git a/src/main/java/com/avaje/ebean/bean/NodeUsageCollector.java b/src/main/java/com/avaje/ebean/bean/NodeUsageCollector.java index 405b36e9f..6eb6333ac 100644 --- a/src/main/java/com/avaje/ebean/bean/NodeUsageCollector.java +++ b/src/main/java/com/avaje/ebean/bean/NodeUsageCollector.java @@ -29,7 +29,7 @@ public final class NodeUsageCollector { /** * The properties used at this profile point. */ - private final Set used = new LinkedHashSet(); + private final Set used = new LinkedHashSet<>(); /** * set to true if the bean is modified (setter called) diff --git a/src/main/java/com/avaje/ebean/bean/ObjectGraphNode.java b/src/main/java/com/avaje/ebean/bean/ObjectGraphNode.java index ef75d3c3c..54344e3ee 100644 --- a/src/main/java/com/avaje/ebean/bean/ObjectGraphNode.java +++ b/src/main/java/com/avaje/ebean/bean/ObjectGraphNode.java @@ -64,15 +64,15 @@ public final class ObjectGraphNode implements Serializable { } public String toString() { - return "origin:" + originQueryPoint + " path[" + path+"]"; + return "origin:" + originQueryPoint + " path[" + path + "]"; } - + public int hashCode() { int hc = 31 * originQueryPoint.hashCode(); hc = 31 * hc + (path == null ? 0 : path.hashCode()); return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -80,10 +80,10 @@ public final class ObjectGraphNode implements Serializable { if (!(obj instanceof ObjectGraphNode)) { return false; } - + ObjectGraphNode e = (ObjectGraphNode) obj; //noinspection StringEquality - return ((e.path == path) || (e.path != null && e.path.equals(path))) - && e.originQueryPoint.equals(originQueryPoint); + return ((e.path == path) || (e.path != null && e.path.equals(path))) + && e.originQueryPoint.equals(originQueryPoint); } } diff --git a/src/main/java/com/avaje/ebean/bean/ObjectGraphOrigin.java b/src/main/java/com/avaje/ebean/bean/ObjectGraphOrigin.java index 1ed7710fb..2b6dd8882 100644 --- a/src/main/java/com/avaje/ebean/bean/ObjectGraphOrigin.java +++ b/src/main/java/com/avaje/ebean/bean/ObjectGraphOrigin.java @@ -58,7 +58,7 @@ public final class ObjectGraphOrigin implements Serializable { } public String toString() { - return "key["+ key + "] type[" + beanType + "] " + callStack.getFirstStackTraceElement()+" "; + return "key[" + key + "] type[" + beanType + "] " + callStack.getFirstStackTraceElement() + " "; } public int hashCode() { @@ -67,7 +67,7 @@ public final class ObjectGraphOrigin implements Serializable { hc = 31 * hc + queryHash; return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -75,10 +75,10 @@ public final class ObjectGraphOrigin implements Serializable { if (!(obj instanceof ObjectGraphOrigin)) { return false; } - + ObjectGraphOrigin e = (ObjectGraphOrigin) obj; - return e.queryHash == queryHash - && e.beanType.equals(beanType) - && e.callStack.equals(callStack); + return e.queryHash == queryHash + && e.beanType.equals(beanType) + && e.callStack.equals(callStack); } } diff --git a/src/main/java/com/avaje/ebean/bean/package.html b/src/main/java/com/avaje/ebean/bean/package.html index 6abde55f5..93554710f 100644 --- a/src/main/java/com/avaje/ebean/bean/package.html +++ b/src/main/java/com/avaje/ebean/bean/package.html @@ -1,12 +1,11 @@ - - Enhanced beans API and Support objects + + Enhanced beans API and Support objects Enhanced beans API and Support objects - - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/cache/ServerCache.java b/src/main/java/com/avaje/ebean/cache/ServerCache.java index e3c64a326..40439ac0f 100644 --- a/src/main/java/com/avaje/ebean/cache/ServerCache.java +++ b/src/main/java/com/avaje/ebean/cache/ServerCache.java @@ -10,7 +10,7 @@ package com.avaje.ebean.cache; * which holds beans of a given type. The other is the 'query cache' holding * query results for a given type. *

- * + * * @author rbygrave */ public interface ServerCache { @@ -52,9 +52,8 @@ public interface ServerCache { /** * Return statistics for the cache. - * - * @param reset - * if true the statistics are reset. + * + * @param reset if true the statistics are reset. */ ServerCacheStatistics getStatistics(boolean reset); } diff --git a/src/main/java/com/avaje/ebean/cache/ServerCacheOptions.java b/src/main/java/com/avaje/ebean/cache/ServerCacheOptions.java index 35c3443f2..1da6527c1 100644 --- a/src/main/java/com/avaje/ebean/cache/ServerCacheOptions.java +++ b/src/main/java/com/avaje/ebean/cache/ServerCacheOptions.java @@ -1,7 +1,7 @@ package com.avaje.ebean.cache; -import com.avaje.ebean.annotation.CacheQueryTuning; import com.avaje.ebean.annotation.CacheBeanTuning; +import com.avaje.ebean.annotation.CacheQueryTuning; /** * Options for controlling a cache. diff --git a/src/main/java/com/avaje/ebean/cache/ServerCacheStatistics.java b/src/main/java/com/avaje/ebean/cache/ServerCacheStatistics.java index a2f290916..56a2a412a 100644 --- a/src/main/java/com/avaje/ebean/cache/ServerCacheStatistics.java +++ b/src/main/java/com/avaje/ebean/cache/ServerCacheStatistics.java @@ -71,7 +71,7 @@ public class ServerCacheStatistics { if (totalCount == 0) { return 0; } else { - return (int)(hitCount * 100 / totalCount); + return (int) (hitCount * 100 / totalCount); } } diff --git a/src/main/java/com/avaje/ebean/cache/package.html b/src/main/java/com/avaje/ebean/cache/package.html index e69e39f09..78e2479a2 100644 --- a/src/main/java/com/avaje/ebean/cache/package.html +++ b/src/main/java/com/avaje/ebean/cache/package.html @@ -1,10 +1,10 @@ - - Server Cache Service + + Server Cache Service Server Cache Service - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java b/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java index d7270fcbf..2512a126d 100644 --- a/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java +++ b/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java @@ -11,10 +11,8 @@ import java.util.Set; /** * Base class for List Set and Map implementations of BeanCollection. - * - * @author rbygrave */ -public abstract class AbstractBeanCollection implements BeanCollection { +abstract class AbstractBeanCollection implements BeanCollection { private static final long serialVersionUID = 3365725236140187588L; @@ -56,13 +54,13 @@ public abstract class AbstractBeanCollection implements BeanCollection { /** * Constructor not non-lazy loading collection. */ - public AbstractBeanCollection() { + AbstractBeanCollection() { } /** * Used to create deferred fetch proxy. */ - public AbstractBeanCollection(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) { + AbstractBeanCollection(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) { this.loader = loader; this.ebeanServerName = loader.getName(); this.ownerBean = ownerBean; @@ -91,14 +89,14 @@ public abstract class AbstractBeanCollection implements BeanCollection { this.disableLazyLoad = disableLazyLoad; } - protected void lazyLoadCollection(boolean onlyIds) { + void lazyLoadCollection(boolean onlyIds) { if (loader == null) { loader = (BeanCollectionLoader) Ebean.getServer(ebeanServerName); } if (loader == null) { String msg = "Lazy loading but LazyLoadEbeanServer is null?" - + " The LazyLoadEbeanServer needs to be set after deserialization" - + " to support lazy loading."; + + " The LazyLoadEbeanServer needs to be set after deserialization" + + " to support lazy loading."; throw new PersistenceException(msg); } @@ -124,7 +122,7 @@ public abstract class AbstractBeanCollection implements BeanCollection { this.readOnly = readOnly; } - protected void checkReadOnly() { + void checkReadOnly() { if (readOnly) { String msg = "This collection is in ReadOnly mode"; throw new IllegalStateException(msg); @@ -157,9 +155,9 @@ public abstract class AbstractBeanCollection implements BeanCollection { return modifyListenMode; } - protected ModifyHolder getModifyHolder() { + ModifyHolder getModifyHolder() { if (modifyHolder == null) { - modifyHolder = new ModifyHolder(); + modifyHolder = new ModifyHolder<>(); } return modifyHolder; } @@ -201,7 +199,7 @@ public abstract class AbstractBeanCollection implements BeanCollection { /** * Return true if there are underlying additions or removals. */ - public boolean holdsModifications() { + boolean holdsModifications() { return modifyHolder != null && modifyHolder.hasModifications(); } } diff --git a/src/main/java/com/avaje/ebean/common/BeanList.java b/src/main/java/com/avaje/ebean/common/BeanList.java index 2b01cd367..c5616a1e2 100644 --- a/src/main/java/com/avaje/ebean/common/BeanList.java +++ b/src/main/java/com/avaje/ebean/common/BeanList.java @@ -37,7 +37,7 @@ public final class BeanList extends AbstractBeanCollection implements List * Uses an ArrayList as the underlying List implementation. */ public BeanList() { - this(new ArrayList()); + this(new ArrayList<>()); } /** @@ -68,7 +68,7 @@ public final class BeanList extends AbstractBeanCollection implements List @SuppressWarnings("unchecked") public void loadFrom(BeanCollection other) { if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); } list.addAll((Collection) other.getActualDetails()); } @@ -76,7 +76,7 @@ public final class BeanList extends AbstractBeanCollection implements List @SuppressWarnings("unchecked") public void internalAdd(Object bean) { if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); } if (bean != null) { list.add((E) bean); @@ -85,14 +85,26 @@ public final class BeanList extends AbstractBeanCollection implements List @Override public void internalAddWithCheck(Object bean) { - if (list == null || !list.contains(bean)) { + if (list == null || !containsInstance(bean)) { internalAdd(bean); } } + /** + * Contains using instance equality for List (specifically not .equals() based). + */ + private boolean containsInstance(Object bean) { + for (Object element : list) { + if (element == bean) { + return true; + } + } + return false; + } + public boolean checkEmptyLazyLoad() { if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); return true; } else { return false; @@ -105,7 +117,7 @@ public final class BeanList extends AbstractBeanCollection implements List if (!disableLazyLoad && modifyListening) { lazyLoadCollection(true); } else { - list = new ArrayList(); + list = new ArrayList<>(); } } } @@ -115,7 +127,7 @@ public final class BeanList extends AbstractBeanCollection implements List synchronized (this) { if (list == null) { if (disableLazyLoad) { - list = new ArrayList(); + list = new ArrayList<>(); } else { lazyLoadCollection(false); } @@ -261,8 +273,8 @@ public final class BeanList extends AbstractBeanCollection implements List // and fetch just the Id's initClear(); if (modifyRemoveListening) { - for (int i = 0; i < list.size(); i++) { - getModifyHolder().modifyRemoval(list.get(i)); + for (E aList : list) { + getModifyHolder().modifyRemoval(aList); } } list.clear(); @@ -296,11 +308,11 @@ public final class BeanList extends AbstractBeanCollection implements List public Iterator iterator() { init(); if (isReadOnly()) { - return new ReadOnlyListIterator(list.listIterator()); + return new ReadOnlyListIterator<>(list.listIterator()); } if (modifyListening) { Iterator it = list.iterator(); - return new ModifyIterator(this, it); + return new ModifyIterator<>(this, it); } return list.iterator(); } @@ -313,11 +325,11 @@ public final class BeanList extends AbstractBeanCollection implements List public ListIterator listIterator() { init(); if (isReadOnly()) { - return new ReadOnlyListIterator(list.listIterator()); + return new ReadOnlyListIterator<>(list.listIterator()); } if (modifyListening) { ListIterator it = list.listIterator(); - return new ModifyListIterator(this, it); + return new ModifyListIterator<>(this, it); } return list.listIterator(); } @@ -325,11 +337,11 @@ public final class BeanList extends AbstractBeanCollection implements List public ListIterator listIterator(int index) { init(); if (isReadOnly()) { - return new ReadOnlyListIterator(list.listIterator(index)); + return new ReadOnlyListIterator<>(list.listIterator(index)); } if (modifyListening) { ListIterator it = list.listIterator(index); - return new ModifyListIterator(this, it); + return new ModifyListIterator<>(this, it); } return list.listIterator(index); } @@ -425,7 +437,7 @@ public final class BeanList extends AbstractBeanCollection implements List return Collections.unmodifiableList(list.subList(fromIndex, toIndex)); } if (modifyListening) { - return new ModifyList(this, list.subList(fromIndex, toIndex)); + return new ModifyList<>(this, list.subList(fromIndex, toIndex)); } return list.subList(fromIndex, toIndex); } diff --git a/src/main/java/com/avaje/ebean/common/BeanMap.java b/src/main/java/com/avaje/ebean/common/BeanMap.java index f046c83f9..232d23a84 100644 --- a/src/main/java/com/avaje/ebean/common/BeanMap.java +++ b/src/main/java/com/avaje/ebean/common/BeanMap.java @@ -33,7 +33,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma * Create using a underlying LinkedHashMap. */ public BeanMap() { - this(new LinkedHashMap()); + this(new LinkedHashMap<>()); } public BeanMap(BeanCollectionLoader ebeanServer, EntityBean ownerBean, String propertyName) { @@ -54,21 +54,21 @@ public final class BeanMap extends AbstractBeanCollection implements Ma @Override @SuppressWarnings("unchecked") public void loadFrom(BeanCollection other) { - BeanMap otherMap = (BeanMap)other; + BeanMap otherMap = (BeanMap) other; internalPutNull(); map.putAll(otherMap.getActualMap()); } public void internalPutNull() { if (map == null) { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); } } - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") public void internalPut(Object key, Object bean) { if (map == null) { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); } if (key != null) { map.put((K) key, (E) bean); @@ -108,7 +108,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma public boolean checkEmptyLazyLoad() { if (map == null) { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); return true; } else { return false; @@ -121,7 +121,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma if (modifyListening) { lazyLoadCollection(true); } else { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); } } } @@ -219,7 +219,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma return map.containsValue(value); } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public Set> entrySet() { init(); if (isReadOnly()) { @@ -265,7 +265,6 @@ public final class BeanMap extends AbstractBeanCollection implements Ma return map.put(key, value); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public void putAll(Map puts) { checkReadOnly(); init(); @@ -314,7 +313,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma } if (modifyListening) { Collection c = map.values(); - return new ModifyCollection(this, c); + return new ModifyCollection<>(this, c); } return map.values(); } diff --git a/src/main/java/com/avaje/ebean/common/BeanSet.java b/src/main/java/com/avaje/ebean/common/BeanSet.java index 67df7ddb2..f7b780681 100644 --- a/src/main/java/com/avaje/ebean/common/BeanSet.java +++ b/src/main/java/com/avaje/ebean/common/BeanSet.java @@ -34,7 +34,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set()); + this(new LinkedHashSet<>()); } public BeanSet(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) { @@ -61,7 +61,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set other) { if (set == null) { - set = new LinkedHashSet(); + set = new LinkedHashSet<>(); } set.addAll((Collection) other.getActualDetails()); } @@ -76,7 +76,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set(); + set = new LinkedHashSet<>(); } if (bean != null) { set.add((E) bean); @@ -100,7 +100,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set(); + set = new LinkedHashSet<>(); return true; } else { return false; @@ -113,7 +113,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set(); + set = new LinkedHashSet<>(); } } } @@ -256,10 +256,10 @@ public final class BeanSet extends AbstractBeanCollection implements Set iterator() { init(); if (isReadOnly()) { - return new ReadOnlyIterator(set.iterator()); + return new ReadOnlyIterator<>(set.iterator()); } if (modifyListening) { - return new ModifyIterator(this, set.iterator()); + return new ModifyIterator<>(this, set.iterator()); } return set.iterator(); } diff --git a/src/main/java/com/avaje/ebean/common/ModifyCollection.java b/src/main/java/com/avaje/ebean/common/ModifyCollection.java index e2aa5eff4..041476768 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyCollection.java +++ b/src/main/java/com/avaje/ebean/common/ModifyCollection.java @@ -1,10 +1,10 @@ package com.avaje.ebean.common; +import com.avaje.ebean.bean.BeanCollection; + import java.util.Collection; import java.util.Iterator; -import com.avaje.ebean.bean.BeanCollection; - /** * Wraps a collection for the purposes of notifying removals and additions to * the BeanCollection owner. @@ -72,7 +72,7 @@ class ModifyCollection implements Collection { @Override public Iterator iterator() { Iterator it = c.iterator(); - return new ModifyIterator(owner, it); + return new ModifyIterator<>(owner, it); } @Override diff --git a/src/main/java/com/avaje/ebean/common/ModifyHolder.java b/src/main/java/com/avaje/ebean/common/ModifyHolder.java index b11f0d39d..9a9180810 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyHolder.java +++ b/src/main/java/com/avaje/ebean/common/ModifyHolder.java @@ -21,16 +21,16 @@ class ModifyHolder implements Serializable { /** * Deletions list for manyToMany persistence. */ - private Set modifyDeletions = new LinkedHashSet(); + private Set modifyDeletions = new LinkedHashSet<>(); /** * Additions list for manyToMany persistence. */ - private Set modifyAdditions = new LinkedHashSet(); + private Set modifyAdditions = new LinkedHashSet<>(); void reset() { - modifyDeletions = new LinkedHashSet(); - modifyAdditions = new LinkedHashSet(); + modifyDeletions = new LinkedHashSet<>(); + modifyAdditions = new LinkedHashSet<>(); } /** diff --git a/src/main/java/com/avaje/ebean/common/ModifyIterator.java b/src/main/java/com/avaje/ebean/common/ModifyIterator.java index 30f6a2e85..08e7a30c7 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyIterator.java +++ b/src/main/java/com/avaje/ebean/common/ModifyIterator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.common; -import java.util.Iterator; - import com.avaje.ebean.bean.BeanCollection; +import java.util.Iterator; + /** * Wraps an iterator for the purposes of notifying removals and additions to the * BeanCollection owner. diff --git a/src/main/java/com/avaje/ebean/common/ModifyList.java b/src/main/java/com/avaje/ebean/common/ModifyList.java index bb2e3afa1..112670dd1 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyList.java +++ b/src/main/java/com/avaje/ebean/common/ModifyList.java @@ -1,11 +1,11 @@ package com.avaje.ebean.common; +import com.avaje.ebean.bean.BeanCollection; + import java.util.Collection; import java.util.List; import java.util.ListIterator; -import com.avaje.ebean.bean.BeanCollection; - /** * Wraps a List for the purposes of notifying removals and additions to the * BeanCollection owner. @@ -61,11 +61,11 @@ class ModifyList extends ModifyCollection implements List { } public ListIterator listIterator() { - return new ModifyListIterator(owner, list.listIterator()); + return new ModifyListIterator<>(owner, list.listIterator()); } public ListIterator listIterator(int index) { - return new ModifyListIterator(owner, list.listIterator(index)); + return new ModifyListIterator<>(owner, list.listIterator(index)); } public E remove(int index) { @@ -82,7 +82,7 @@ class ModifyList extends ModifyCollection implements List { } public List subList(int fromIndex, int toIndex) { - return new ModifyList(owner, list.subList(fromIndex, toIndex)); + return new ModifyList<>(owner, list.subList(fromIndex, toIndex)); } } diff --git a/src/main/java/com/avaje/ebean/common/ModifyListIterator.java b/src/main/java/com/avaje/ebean/common/ModifyListIterator.java index 82a6cc738..d6155b6af 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyListIterator.java +++ b/src/main/java/com/avaje/ebean/common/ModifyListIterator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.common; -import java.util.ListIterator; - import com.avaje.ebean.bean.BeanCollection; +import java.util.ListIterator; + /** * Wraps a ListIterator for the purposes of notifying removals and additions to * the BeanCollection owner. diff --git a/src/main/java/com/avaje/ebean/common/ModifySet.java b/src/main/java/com/avaje/ebean/common/ModifySet.java index 6d9ebc2dc..8cacde77d 100644 --- a/src/main/java/com/avaje/ebean/common/ModifySet.java +++ b/src/main/java/com/avaje/ebean/common/ModifySet.java @@ -1,9 +1,9 @@ package com.avaje.ebean.common; -import java.util.Set; - import com.avaje.ebean.bean.BeanCollection; +import java.util.Set; + /** * Wraps a Set for the purposes of notifying removals and additions to the * BeanCollection owner. diff --git a/src/main/java/com/avaje/ebean/common/SpiContainer.java b/src/main/java/com/avaje/ebean/common/SpiContainer.java index ed3c000a7..2715576de 100644 --- a/src/main/java/com/avaje/ebean/common/SpiContainer.java +++ b/src/main/java/com/avaje/ebean/common/SpiContainer.java @@ -11,9 +11,8 @@ public interface SpiContainer { /** * Create the EbeanServer for a given configuration. - * - * @param configuration - * The configuration information for this server. + * + * @param configuration The configuration information for this server. */ EbeanServer createServer(ServerConfig configuration); diff --git a/src/main/java/com/avaje/ebean/common/package.html b/src/main/java/com/avaje/ebean/common/package.html index 21956c462..924650876 100644 --- a/src/main/java/com/avaje/ebean/common/package.html +++ b/src/main/java/com/avaje/ebean/common/package.html @@ -1,11 +1,11 @@ - - Common non-public interfaces and implementation + + Common non-public interfaces and implementation Common non-public interfaces and implementation. - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/config/AbstractNamingConvention.java b/src/main/java/com/avaje/ebean/config/AbstractNamingConvention.java index 5a07a44ef..3f836a709 100644 --- a/src/main/java/com/avaje/ebean/config/AbstractNamingConvention.java +++ b/src/main/java/com/avaje/ebean/config/AbstractNamingConvention.java @@ -2,8 +2,10 @@ package com.avaje.ebean.config; import com.avaje.ebean.config.dbplatform.DatabasePlatform; +import javax.persistence.DiscriminatorValue; import javax.persistence.Inheritance; import javax.persistence.Table; +import java.lang.annotation.Annotation; /** * Provides some base implementation for NamingConventions. @@ -182,11 +184,9 @@ public abstract class AbstractNamingConvention implements NamingConvention { TableName tableName = getTableNameFromAnnotation(beanClass); if (tableName == null) { - Class supCls = beanClass.getSuperclass(); - Inheritance inheritance = supCls.getAnnotation(Inheritance.class); - if (inheritance != null) { - // get the table as per inherited class in case their + if (hasInheritance(supCls)) { + // get the table as per inherited class in case there // is not a table annotation in the inheritance hierarchy return getTableName(supCls); } @@ -207,6 +207,20 @@ public abstract class AbstractNamingConvention implements NamingConvention { return new TableName(catalog, schema, tableName.getName()); } + /** + * Return true if this class is part of entity inheritance. + */ + protected boolean hasInheritance(Class supCls) { + return hasAnnotation(supCls, Inheritance.class) || hasAnnotation(supCls, DiscriminatorValue.class); + } + + /** + * Return true if the class has the given annotation. + */ + protected boolean hasAnnotation(Class supCls, Class annotation) { + return supCls.getAnnotation(annotation) != null; + } + public TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable) { StringBuilder buffer = new StringBuilder(); diff --git a/src/main/java/com/avaje/ebean/config/AutoTuneConfig.java b/src/main/java/com/avaje/ebean/config/AutoTuneConfig.java index 85e5306b1..71373c575 100644 --- a/src/main/java/com/avaje/ebean/config/AutoTuneConfig.java +++ b/src/main/java/com/avaje/ebean/config/AutoTuneConfig.java @@ -24,7 +24,7 @@ public class AutoTuneConfig { private int profilingUpdateFrequency; private int garbageCollectionWait = 100; - + private boolean skipGarbageCollectionOnShutdown; private boolean skipProfileReportingOnShutdown; diff --git a/src/main/java/com/avaje/ebean/config/ClassLoadConfig.java b/src/main/java/com/avaje/ebean/config/ClassLoadConfig.java index 1adf6d32c..a76547c4f 100644 --- a/src/main/java/com/avaje/ebean/config/ClassLoadConfig.java +++ b/src/main/java/com/avaje/ebean/config/ClassLoadConfig.java @@ -137,7 +137,7 @@ public class ClassLoadConfig { ClassLoader contextLoader() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); - return (loader != null) ? loader: callerLoader; + return (loader != null) ? loader : callerLoader; } Enumeration getResources(String name) throws IOException { diff --git a/src/main/java/com/avaje/ebean/config/CompoundType.java b/src/main/java/com/avaje/ebean/config/CompoundType.java index 59e704a40..c0ffcbda6 100644 --- a/src/main/java/com/avaje/ebean/config/CompoundType.java +++ b/src/main/java/com/avaje/ebean/config/CompoundType.java @@ -3,7 +3,6 @@ package com.avaje.ebean.config; /** * API from creating and getting property values from an Immutable Compound * Value Object. - * *

* A Compound Value object should contain multiple properties that are stored * separately. If you only have a single scalar value you should instead look to @@ -24,12 +23,9 @@ package com.avaje.ebean.config; * implementations of this interface (along with detecting the entity classes * etc). *

- * + * + * @param The type of the Value Object * @author rbygrave - * - * @param - * The type of the Value Object - * * @see ScalarTypeConverter */ public interface CompoundType { diff --git a/src/main/java/com/avaje/ebean/config/CompoundTypeProperty.java b/src/main/java/com/avaje/ebean/config/CompoundTypeProperty.java index 30075b328..b7a22fb7c 100644 --- a/src/main/java/com/avaje/ebean/config/CompoundTypeProperty.java +++ b/src/main/java/com/avaje/ebean/config/CompoundTypeProperty.java @@ -5,16 +5,11 @@ package com.avaje.ebean.config; *

* For each property in a {@link CompoundType} you need an implementation of * this CompoundTypeProperty interface. - * *

- * + * + * @param The type of the Compound value object + * @param

The type of the property * @author rbygrave - * - * @param - * The type of the Compound value object - * @param

- * The type of the property - * * @see CompoundType * @see ScalarTypeConverter */ @@ -27,9 +22,8 @@ public interface CompoundTypeProperty { /** * Return the property value from the containing compound value object. - * - * @param valueObject - * the compound value object + * + * @param valueObject the compound value object * @return the property value. */ P getValue(V valueObject); @@ -43,9 +37,9 @@ public interface CompoundTypeProperty { * persistence type is java.sql.Timestamp. In this case return * java.sql.Types.TIMESTAMP (rather than 0). *

- * + * * @return Return the java.sql.Type that you want to use to persist this - * property or 0 and Ebean will use the logical type. + * property or 0 and Ebean will use the logical type. */ int getDbType(); } diff --git a/src/main/java/com/avaje/ebean/config/CurrentUserProvider.java b/src/main/java/com/avaje/ebean/config/CurrentUserProvider.java index 3980cd163..7de4a361f 100644 --- a/src/main/java/com/avaje/ebean/config/CurrentUserProvider.java +++ b/src/main/java/com/avaje/ebean/config/CurrentUserProvider.java @@ -8,8 +8,8 @@ public interface CurrentUserProvider { /** * Return the current user id. *

- * The type returned should match the type of the properties annotated - * with @WhoCreated and @WhoModified. These are typically String, Long or UUID. + * The type returned should match the type of the properties annotated + * with @WhoCreated and @WhoModified. These are typically String, Long or UUID. *

*/ Object currentUser(); diff --git a/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java b/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java index 8779af15f..7a4ac320c 100644 --- a/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java +++ b/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java @@ -78,8 +78,8 @@ public class DbConstraintNormalise { public boolean notQuoted(String tableName) { // remove quoted identifier characters - for (int i = 0; i < quotedIdentifiers.length; i++) { - if (tableName.contains(quotedIdentifiers[i])) { + for (String quotedIdentifier : quotedIdentifiers) { + if (tableName.contains(quotedIdentifier)) { return false; } } @@ -95,8 +95,8 @@ public class DbConstraintNormalise { return ""; } // remove quoted identifier characters - for (int i = 0; i < quotedIdentifiers.length; i++) { - tableName = tableName.replace(quotedIdentifiers[i], ""); + for (String quotedIdentifier : quotedIdentifiers) { + tableName = tableName.replace(quotedIdentifier, ""); } return tableName; } diff --git a/src/main/java/com/avaje/ebean/config/DbMigrationConfig.java b/src/main/java/com/avaje/ebean/config/DbMigrationConfig.java index 5e4155289..d3b7dccc6 100644 --- a/src/main/java/com/avaje/ebean/config/DbMigrationConfig.java +++ b/src/main/java/com/avaje/ebean/config/DbMigrationConfig.java @@ -93,7 +93,7 @@ public class DbMigrationConfig { /** * Map of key/value placeholders to replace in DDL scripts. */ - protected Map runPlaceholderMap; + protected Map runPlaceholderMap; /** * DB user used to run the DB migration. @@ -107,7 +107,7 @@ public class DbMigrationConfig { /** * Return the DB platform to generate migration DDL for. - * + *

* We typically need to explicitly specify this as migration can often be generated * when running against H2. */ @@ -375,12 +375,12 @@ public class DbMigrationConfig { metaTable = properties.get("migration.metaTable", metaTable); runPlaceholders = properties.get("migration.placeholders", runPlaceholders); - String adminUser = properties.get("datasource."+serverName+".username", dbUsername); - adminUser = properties.get("datasource."+serverName+".adminusername", adminUser); + String adminUser = properties.get("datasource." + serverName + ".username", dbUsername); + adminUser = properties.get("datasource." + serverName + ".adminusername", adminUser); dbUsername = properties.get("migration.dbusername", adminUser); - String adminPwd = properties.get("datasource."+serverName+".password", dbPassword); - adminPwd = properties.get("datasource."+serverName+".adminpassword", adminPwd); + String adminPwd = properties.get("datasource." + serverName + ".password", dbPassword); + adminPwd = properties.get("datasource." + serverName + ".adminpassword", adminPwd); dbPassword = properties.get("migration.dbpassword", adminPwd); } @@ -403,7 +403,6 @@ public class DbMigrationConfig { /** * Called by EbeanServer on start. - * *

* If enabled this generates the migration xml and DDL scripts. *

diff --git a/src/main/java/com/avaje/ebean/config/DbTypeConfig.java b/src/main/java/com/avaje/ebean/config/DbTypeConfig.java new file mode 100644 index 000000000..64c45ade4 --- /dev/null +++ b/src/main/java/com/avaje/ebean/config/DbTypeConfig.java @@ -0,0 +1,123 @@ +package com.avaje.ebean.config; + +import com.avaje.ebean.config.dbplatform.DbType; +import com.avaje.ebean.config.dbplatform.IdType; + +import java.util.ArrayList; +import java.util.List; + +/** + * Configuration for DB types such as UUID, Geometry etc. + */ +public class DbTypeConfig { + + /** + * The Geometry SRID value (default 4326). + */ + private int geometrySRID = 4326; + + /** + * Set for DB's that support both Sequence and Identity (and the default choice is not desired). + */ + private IdType idType; + + /** + * Setting to indicate if UUID should be stored as binary(16) or varchar(40) or native DB type (for H2 and Postgres). + */ + private ServerConfig.DbUuid dbUuid = ServerConfig.DbUuid.AUTO_VARCHAR; + + /** + * Modify the default mapping of standard types such as default precision for DECIMAL etc. + */ + private List customDbTypeMappings = new ArrayList<>(); + + /** + * Return the Geometry SRID. + */ + public int getGeometrySRID() { + return geometrySRID; + } + + /** + * Set the Geometry SRID. + */ + public void setGeometrySRID(int geometrySRID) { + this.geometrySRID = geometrySRID; + } + + /** + * Return the DB type used to store UUID. + */ + public ServerConfig.DbUuid getDbUuid() { + return dbUuid; + } + + /** + * Set the DB type used to store UUID. + */ + public void setDbUuid(ServerConfig.DbUuid dbUuid) { + this.dbUuid = dbUuid; + } + + /** + * Return the IdType to use (or null for the default choice). + */ + public IdType getIdType() { + return idType; + } + + /** + * Set the IdType to use (when the DB supports both SEQUENCE and IDENTITY and the default is not desired). + */ + public void setIdType(IdType idType) { + this.idType = idType; + } + + /** + * Add a custom type mapping. + *

+ *

{@code
+   *
+   *   // set the default mapping for BigDecimal.class/decimal
+   *   serverConfig.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
+   *
+   *   // set the default mapping for String.class/varchar but only for Postgres
+   *   serverConfig.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
+   *
+   * }
+ * + * @param type The DB type this mapping should apply to + * @param columnDefinition The column definition that should be used + * @param platform Optionally specify the platform this mapping should apply to. + */ + public void addCustomMapping(DbType type, String columnDefinition, Platform platform) { + customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition, platform)); + } + + /** + * Add a custom type mapping that applies to all platforms. + *

+ *

{@code
+   *
+   *   // set the default mapping for BigDecimal/decimal
+   *   serverConfig.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
+   *
+   *   // set the default mapping for String/varchar
+   *   serverConfig.addCustomMapping(DbType.VARCHAR, "text");
+   *
+   * }
+ * + * @param type The DB type this mapping should apply to + * @param columnDefinition The column definition that should be used + */ + public void addCustomMapping(DbType type, String columnDefinition) { + customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition)); + } + + /** + * Return the list of custom type mappings. + */ + public List getCustomTypeMappings() { + return customDbTypeMappings; + } +} diff --git a/src/main/java/com/avaje/ebean/config/EncryptDeploy.java b/src/main/java/com/avaje/ebean/config/EncryptDeploy.java index f19dc4d14..a6a776289 100644 --- a/src/main/java/com/avaje/ebean/config/EncryptDeploy.java +++ b/src/main/java/com/avaje/ebean/config/EncryptDeploy.java @@ -6,9 +6,7 @@ package com.avaje.ebean.config; * You can define the encryption options for a Bean property via the Encrypt * annotation and programmatically via {@link EncryptDeployManager}. *

- * - * @author rbygrave - * + * * @see EncryptDeployManager#getEncryptDeploy(TableName, String) */ public class EncryptDeploy { @@ -67,14 +65,11 @@ public class EncryptDeploy { /** * Construct with all options for Encryption including the dbLength. - * - * @param mode - * the Encryption mode - * @param dbEncrypt - * set to false if you want to use Java client side encryption rather - * than DB encryption. - * @param dbLength - * set the DB length to use. + * + * @param mode the Encryption mode + * @param dbEncrypt set to false if you want to use Java client side encryption rather + * than DB encryption. + * @param dbLength set the DB length to use. */ public EncryptDeploy(Mode mode, boolean dbEncrypt, int dbLength) { this.mode = mode; diff --git a/src/main/java/com/avaje/ebean/config/EncryptDeployManager.java b/src/main/java/com/avaje/ebean/config/EncryptDeployManager.java index dfe800928..38d702f98 100644 --- a/src/main/java/com/avaje/ebean/config/EncryptDeployManager.java +++ b/src/main/java/com/avaje/ebean/config/EncryptDeployManager.java @@ -2,9 +2,6 @@ package com.avaje.ebean.config; /** * Programmatically define which database columns are encrypted. - * - * @author rbygrave - * */ public interface EncryptDeployManager { diff --git a/src/main/java/com/avaje/ebean/config/EncryptKey.java b/src/main/java/com/avaje/ebean/config/EncryptKey.java index 3318b8387..5fd142152 100644 --- a/src/main/java/com/avaje/ebean/config/EncryptKey.java +++ b/src/main/java/com/avaje/ebean/config/EncryptKey.java @@ -5,9 +5,6 @@ package com.avaje.ebean.config; *

* For simple cases this often represent a simple String key but depending on * the encryption method this could contain other details. - *

- * - * @author rbygrave */ public interface EncryptKey { diff --git a/src/main/java/com/avaje/ebean/config/EncryptKeyManager.java b/src/main/java/com/avaje/ebean/config/EncryptKeyManager.java index 8c785db59..43dd90ab8 100644 --- a/src/main/java/com/avaje/ebean/config/EncryptKeyManager.java +++ b/src/main/java/com/avaje/ebean/config/EncryptKeyManager.java @@ -2,8 +2,6 @@ package com.avaje.ebean.config; /** * Determine keys used for encryption and decryption. - * - * @author rbygrave */ public interface EncryptKeyManager { diff --git a/src/main/java/com/avaje/ebean/config/Encryptor.java b/src/main/java/com/avaje/ebean/config/Encryptor.java index d2aa540c8..e696e544c 100644 --- a/src/main/java/com/avaje/ebean/config/Encryptor.java +++ b/src/main/java/com/avaje/ebean/config/Encryptor.java @@ -4,10 +4,6 @@ package com.avaje.ebean.config; * Used for Java side encryption of properties when DB encryption is not used. *

* By default this is used on non-varchar types such as Blobs. - *

- * - * @author rbygrave - * */ public interface Encryptor { diff --git a/src/main/java/com/avaje/ebean/config/MatchingNamingConvention.java b/src/main/java/com/avaje/ebean/config/MatchingNamingConvention.java index a505f99ce..bf871e4b4 100644 --- a/src/main/java/com/avaje/ebean/config/MatchingNamingConvention.java +++ b/src/main/java/com/avaje/ebean/config/MatchingNamingConvention.java @@ -3,13 +3,12 @@ package com.avaje.ebean.config; /** * The JPA naming convention where column names match property names and table * names match entity names. - * *

* The JPA specification states that the in the case of no annotations the name * of the class will be take as the table name and the name of a property will * be taken as the name of the column. *

- * + * * @author emcgreal */ public class MatchingNamingConvention extends AbstractNamingConvention { @@ -23,9 +22,8 @@ public class MatchingNamingConvention extends AbstractNamingConvention { /** * Instantiates with a specific format for DB sequences. - * - * @param sequenceFormat - * the sequence format + * + * @param sequenceFormat the sequence format */ public MatchingNamingConvention(String sequenceFormat) { super(sequenceFormat); diff --git a/src/main/java/com/avaje/ebean/config/NamingConvention.java b/src/main/java/com/avaje/ebean/config/NamingConvention.java index c20854cb3..d86733112 100644 --- a/src/main/java/com/avaje/ebean/config/NamingConvention.java +++ b/src/main/java/com/avaje/ebean/config/NamingConvention.java @@ -26,9 +26,8 @@ public interface NamingConvention { * The purpose of this is to enable NamingConvention to be able to support * database platform specific configuration. *

- * - * @param databasePlatform - * the database platform + * + * @param databasePlatform the database platform */ void setDatabasePlatform(DatabasePlatform databasePlatform); @@ -39,29 +38,24 @@ public interface NamingConvention { * annotations etc. This means you can choose to override the settings defined * by @Table if you wish. *

- * - * @param beanClass - * the bean class - * + * + * @param beanClass the bean class * @return the table name for the entity class */ TableName getTableName(Class beanClass); /** * Returns the ManyToMany join table name (aka the intersection table). - * - * @param lhsTable - * the left hand side bean table - * @param rhsTable - * the right hand side bean table - * + * + * @param lhsTable the left hand side bean table + * @param rhsTable the right hand side bean table * @return the many to many join table name */ TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable); /** * Return the column name given the property name. - * + * * @return the column name for a given property */ String getColumnFromProperty(Class beanClass, String propertyName); @@ -71,12 +65,9 @@ public interface NamingConvention { *

* This is used to help mapping of raw SQL queries onto bean properties. *

- * - * @param beanClass - * the bean class - * @param dbColumnName - * the db column name - * + * + * @param beanClass the bean class + * @param dbColumnName the db column name * @return the property name from the column name */ String getPropertyFromColumn(Class beanClass, String dbColumnName); @@ -86,10 +77,8 @@ public interface NamingConvention { *

* Typically you might append "_seq" to the table name as an example. *

- * - * @param tableName - * the table name - * + * + * @param tableName the table name * @return the sequence name */ String getSequenceName(String tableName, String pkColumn); @@ -116,4 +105,4 @@ public interface NamingConvention { */ void loadFromProperties(PropertiesWrapper properties); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/config/PersistBatch.java b/src/main/java/com/avaje/ebean/config/PersistBatch.java index 305372d95..b49e1d9b4 100644 --- a/src/main/java/com/avaje/ebean/config/PersistBatch.java +++ b/src/main/java/com/avaje/ebean/config/PersistBatch.java @@ -8,7 +8,6 @@ package com.avaje.ebean.config; * * @see com.avaje.ebean.config.ServerConfig#setPersistBatch(PersistBatch) * @see com.avaje.ebean.config.ServerConfig#setPersistBatchOnCascade(PersistBatch) - * * @see com.avaje.ebean.Transaction#setBatch(PersistBatch) * @see com.avaje.ebean.Transaction#setBatchOnCascade(PersistBatch) */ diff --git a/src/main/java/com/avaje/ebean/config/PropertyExpression.java b/src/main/java/com/avaje/ebean/config/PropertyExpression.java index 67c5bc1df..64c9f88c9 100644 --- a/src/main/java/com/avaje/ebean/config/PropertyExpression.java +++ b/src/main/java/com/avaje/ebean/config/PropertyExpression.java @@ -149,9 +149,8 @@ final class PropertyExpression { /** * Returns null if JNDI is not setup or if the property is not found. - * - * @param key - * the key of the JNDI Environment property including a JNDI: prefix. + * + * @param key the key of the JNDI Environment property including a JNDI: prefix. */ private static String getJndiProperty(String key) { @@ -176,4 +175,4 @@ final class PropertyExpression { return ctx.lookup(JAVA_COMP_ENV + key); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/config/PropertyMap.java b/src/main/java/com/avaje/ebean/config/PropertyMap.java index 8e2f8db70..3c9482953 100644 --- a/src/main/java/com/avaje/ebean/config/PropertyMap.java +++ b/src/main/java/com/avaje/ebean/config/PropertyMap.java @@ -16,7 +16,7 @@ public final class PropertyMap implements Serializable { private static final long serialVersionUID = 1L; - private final LinkedHashMap map = new LinkedHashMap(); + private final LinkedHashMap map = new LinkedHashMap<>(); /** * Return properties loaded from test-ebean.properties. diff --git a/src/main/java/com/avaje/ebean/config/PropertyMapLoader.java b/src/main/java/com/avaje/ebean/config/PropertyMapLoader.java index 2532786c2..b237b38c4 100644 --- a/src/main/java/com/avaje/ebean/config/PropertyMapLoader.java +++ b/src/main/java/com/avaje/ebean/config/PropertyMapLoader.java @@ -3,7 +3,11 @@ package com.avaje.ebean.config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.util.Map; import java.util.Properties; @@ -49,11 +53,9 @@ final class PropertyMapLoader { /** * Load the file returning the property map. - * - * @param p - * an existing property map to load into. - * @param fileName - * the name of the properties file to load. + * + * @param p an existing property map to load into. + * @param fileName the name of the properties file to load. */ public static PropertyMap load(PropertyMap p, String fileName) { @@ -67,11 +69,9 @@ final class PropertyMapLoader { /** * Load the InputStream returning the property map. - * - * @param p - * an existing property map to load into. - * @param in - * the InputStream of the properties file to load. + * + * @param p an existing property map to load into. + * @param in the InputStream of the properties file to load. */ public static PropertyMap load(PropertyMap p, InputStream in) { diff --git a/src/main/java/com/avaje/ebean/config/ScalarTypeConverter.java b/src/main/java/com/avaje/ebean/config/ScalarTypeConverter.java index 1e61f5a71..a0fbb1d47 100644 --- a/src/main/java/com/avaje/ebean/config/ScalarTypeConverter.java +++ b/src/main/java/com/avaje/ebean/config/ScalarTypeConverter.java @@ -26,14 +26,10 @@ package com.avaje.ebean.config; * If you want to support a Compound Type rather than a Scalar Type refer to * {@link CompoundType}. *

- * + * + * @param The value object type. + * @param The scalar object type that is used to persist the value object. * @author rbygrave - * - * @param - * The value object type. - * @param - * The scalar object type that is used to persist the value object. - * * @see CompoundType * @see CompoundTypeProperty */ @@ -52,9 +48,8 @@ public interface ScalarTypeConverter { * This typically occurs when Ebean reads the value from a resultSet or other * data source. *

- * - * @param scalarType - * the value from the data source + * + * @param scalarType the value from the data source */ B wrapValue(S scalarType); @@ -65,9 +60,8 @@ public interface ScalarTypeConverter { * This typically occurs when Ebean is persisting the value object to the data * store. *

- * - * @param beanType - * the value object + * + * @param beanType the value object */ S unwrapValue(B beanType); diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index 2f0230220..374b4083e 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -46,7 +46,6 @@ import java.util.ServiceLoader; * includes searching the class path and automatically registering any entity * classes and listeners etc. *

- * *
{@code
  *
  * ServerConfig c = new ServerConfig();
@@ -77,16 +76,20 @@ public class ServerConfig {
    */
   private String name = "db";
 
+  /**
+   * When false (default) H2 automatically uses DDL generate and run
+   * (i.e. assumes we are running tests using in memory h2).
+   */
+  private boolean h2ProductionMode;
+
   /**
    * Typically configuration type objects that are passed by this ServerConfig
    * to plugins. For example - IgniteConfiguration passed to Ignite plugin.
    */
-  private Map serviceObject = new HashMap();
+  private Map serviceObject = new HashMap<>();
 
   private ContainerConfig containerConfig;
 
-  private List customDbTypeMappings = new ArrayList();
-
   /**
    * The underlying properties that were used during configuration.
    */
@@ -112,22 +115,17 @@ public class ServerConfig {
    */
   private boolean disableClasspathSearch;
 
-  /**
-   * The Geometry SRID value (default 4326).
-   */
-  private int geometrySRID = 4326;
-
   /**
    * List of interesting classes such as entities, embedded, ScalarTypes,
    * Listeners, Finders, Controllers etc.
    */
-  private List> classes = new ArrayList>();
+  private List> classes = new ArrayList<>();
 
   /**
    * The packages that are searched for interesting classes. Only used when
    * classes is empty/not explicitly specified.
    */
-  private List packages = new ArrayList();
+  private List packages = new ArrayList<>();
 
   /**
    * Configuration for the ElasticSearch integration.
@@ -326,20 +324,19 @@ public class ServerConfig {
   private boolean updatesDeleteMissingChildren = true;
 
   /**
-   * Setting to indicate if UUID should be stored as binary(16) or varchar(40) or native DB type (for H2 and Postgres).
+   * Database type configuration.
    */
-  private DbUuid dbUuid = DbUuid.AUTO_VARCHAR;
+  private DbTypeConfig dbTypeConfig = new DbTypeConfig();
 
-
-  private List idGenerators = new ArrayList();
-  private List findControllers = new ArrayList();
-  private List persistControllers = new ArrayList();
-  private List postLoaders = new ArrayList();
-  private List postConstructListeners = new ArrayList();
-  private List persistListeners = new ArrayList();
-  private List queryAdapters = new ArrayList();
-  private List bulkTableEventListeners = new ArrayList();
-  private List configStartupListeners = new ArrayList();
+  private List idGenerators = new ArrayList<>();
+  private List findControllers = new ArrayList<>();
+  private List persistControllers = new ArrayList<>();
+  private List postLoaders = new ArrayList<>();
+  private List postConstructListeners = new ArrayList<>();
+  private List persistListeners = new ArrayList<>();
+  private List queryAdapters = new ArrayList<>();
+  private List bulkTableEventListeners = new ArrayList<>();
+  private List configStartupListeners = new ArrayList<>();
 
   /**
    * By default inserts are included in the change log.
@@ -509,6 +506,27 @@ public class ServerConfig {
     this.name = name;
   }
 
+  /**
+   * Return true if H2 should be used in production mode.
+   * 

+ * Otherwise it is assumed we are using H2 for testing and DDL generate and run is turned on. + *

+ */ + public boolean isH2ProductionMode() { + return h2ProductionMode; + } + + /** + * Set to true for H2 to be used in production mode. + *

+ * Do this when we want to use H2 and not have the DDL generation and run automatically turned on. + * Otherwise it is assumed we are using H2 for testing purposes. + *

+ */ + public void setH2ProductionMode(boolean h2ProductionMode) { + this.h2ProductionMode = h2ProductionMode; + } + /** * Return the container / clustering configuration. *

@@ -885,14 +903,14 @@ public class ServerConfig { * Return the Geometry SRID. */ public int getGeometrySRID() { - return geometrySRID; + return dbTypeConfig.getGeometrySRID(); } /** * Set the Geometry SRID. */ public void setGeometrySRID(int geometrySRID) { - this.geometrySRID = geometrySRID; + dbTypeConfig.setGeometrySRID(geometrySRID); } /** @@ -1444,6 +1462,11 @@ public class ServerConfig { */ public void setDatabasePlatform(DatabasePlatform databasePlatform) { this.databasePlatform = databasePlatform; + if (!h2ProductionMode && databasePlatform != null && databasePlatform.isPlatform(Platform.H2)) { + // we are using H2 to run tests so turn on DDL generation and run + this.ddlGenerate = true; + this.ddlRun = true; + } } /** @@ -1536,17 +1559,17 @@ public class ServerConfig { } /** - * Return the DB type used to store UUID. + * Return the configuration for DB types (such as UUID and custom mappings). */ - public DbUuid getDbUuid() { - return dbUuid; + public DbTypeConfig getDbTypeConfig() { + return dbTypeConfig; } /** * Set the DB type used to store UUID. */ public void setDbUuid(DbUuid dbUuid) { - this.dbUuid = dbUuid; + this.dbTypeConfig.setDbUuid(dbUuid); } /** @@ -1726,7 +1749,7 @@ public class ServerConfig { */ public void addClass(Class cls) { if (classes == null) { - classes = new ArrayList>(); + classes = new ArrayList<>(); } classes.add(cls); } @@ -1739,7 +1762,7 @@ public class ServerConfig { */ public void addPackage(String packageName) { if (packages == null) { - packages = new ArrayList(); + packages = new ArrayList<>(); } packages.add(packageName); } @@ -1974,7 +1997,7 @@ public class ServerConfig { * @param platform Optionally specify the platform this mapping should apply to. */ public void addCustomMapping(DbType type, String columnDefinition, Platform platform) { - customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition, platform)); + dbTypeConfig.addCustomMapping(type, columnDefinition, platform); } /** @@ -1994,14 +2017,7 @@ public class ServerConfig { * @param columnDefinition The column definition that should be used */ public void addCustomMapping(DbType type, String columnDefinition) { - customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition)); - } - - /** - * Return the list of custom type mappings. - */ - public List getCustomTypeMappings() { - return customDbTypeMappings; + dbTypeConfig.addCustomMapping(type, columnDefinition); } /** @@ -2085,7 +2101,8 @@ public class ServerConfig { */ public void add(BeanPostConstructListener listener) { postConstructListeners.add(listener); - } + } + /** * Return the list of BeanFindController instances. */ @@ -2127,6 +2144,7 @@ public class ServerConfig { public void setPostConstructListeners(List listeners) { this.postConstructListeners = listeners; } + /** * Return the BeanPersistController instances. */ @@ -2311,7 +2329,6 @@ public class ServerConfig { * @param key properties key * @param instance existing instance */ - @SuppressWarnings("unchecked") protected T createInstance(PropertiesWrapper properties, Class pluginType, String key, T instance) { if (instance != null) { @@ -2327,6 +2344,7 @@ public class ServerConfig { * @param pluginType the type of plugin * @param classname the implementation class as per properties */ + @SuppressWarnings("unchecked") protected T createInstance(Class pluginType, String classname) { return classname == null ? null : (T) classLoadConfig.newInstance(classname); } @@ -2382,7 +2400,11 @@ public class ServerConfig { } loadDocStoreSettings(p); - geometrySRID = p.getInt("geometrySRID", geometrySRID); + int srid = p.getInt("geometrySRID", 0); + if (srid > 0) { + dbTypeConfig.setGeometrySRID(srid); + } + disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache); explicitTransactionBeginMode = p.getBoolean("explicitTransactionBeginMode", explicitTransactionBeginMode); autoCommitMode = p.getBoolean("autoCommitMode", autoCommitMode); @@ -2442,9 +2464,13 @@ public class ServerConfig { databaseBooleanTrue = p.get("databaseBooleanTrue", databaseBooleanTrue); databaseBooleanFalse = p.get("databaseBooleanFalse", databaseBooleanFalse); databasePlatformName = p.get("databasePlatformName", databasePlatformName); - dbUuid = p.getEnum(DbUuid.class, "dbuuid", dbUuid); + + DbUuid dbUuid = p.getEnum(DbUuid.class, "dbuuid", null); + if (dbUuid != null) { + dbTypeConfig.setDbUuid(dbUuid); + } if (p.getBoolean("uuidStoreAsBinary", false)) { - dbUuid = DbUuid.BINARY; + dbTypeConfig.setDbUuid(DbUuid.BINARY); } localTimeWithNanos = p.getBoolean("localTimeWithNanos", localTimeWithNanos); jodaLocalTimeMode = p.get("jodaLocalTimeMode", jodaLocalTimeMode); @@ -2460,6 +2486,7 @@ public class ServerConfig { jsonDateTime = JsonConfig.DateTime.MILLIS; } + h2ProductionMode = p.getBoolean("h2ProductionMode", h2ProductionMode); ddlGenerate = p.getBoolean("ddl.generate", ddlGenerate); ddlRun = p.getBoolean("ddl.run", ddlRun); ddlCreateOnly = p.getBoolean("ddl.createOnly", ddlCreateOnly); @@ -2488,11 +2515,11 @@ public class ServerConfig { return classes; } - List> classes = new ArrayList>(); + List> classes = new ArrayList<>(); String[] split = classNames.split("[ ,;]"); - for (int i = 0; i < split.length; i++) { - String cn = split[i].trim(); + for (String aSplit : split) { + String cn = aSplit.trim(); if (!cn.isEmpty() && !"class".equalsIgnoreCase(cn)) { try { classes.add(Class.forName(cn)); @@ -2507,13 +2534,13 @@ public class ServerConfig { private List getSearchJarsPackages(String searchPackages) { - List hitList = new ArrayList(); + List hitList = new ArrayList<>(); if (searchPackages != null) { String[] entries = searchPackages.split("[ ,;]"); - for (int i = 0; i < entries.length; i++) { - hitList.add(entries[i].trim()); + for (String entry : entries) { + hitList.add(entry.trim()); } } return hitList; diff --git a/src/main/java/com/avaje/ebean/config/TableName.java b/src/main/java/com/avaje/ebean/config/TableName.java index 2dbe5d023..8d3007011 100644 --- a/src/main/java/com/avaje/ebean/config/TableName.java +++ b/src/main/java/com/avaje/ebean/config/TableName.java @@ -2,18 +2,24 @@ package com.avaje.ebean.config; /** * TableName holds catalog, schema and table name. - * + * * @author emcgreal */ public final class TableName { - /** The catalog. */ + /** + * The catalog. + */ private String catalog; - /** The schema. */ + /** + * The schema. + */ private String schema; - /** The name. */ + /** + * The name. + */ private String name; /** @@ -36,10 +42,9 @@ public final class TableName { * The qualifiedTableName can take the form of catalog.schema.tableName and is * split on the '.' period character. The catalog and schema are optional. *

- * - * @param qualifiedTableName - * the fully qualified table name using '.' between schema and table - * name etc (with catalog and schema optional). + * + * @param qualifiedTableName the fully qualified table name using '.' between schema and table + * name etc (with catalog and schema optional). */ public TableName(String qualifiedTableName) { String[] split = qualifiedTableName.split("\\."); @@ -63,14 +68,14 @@ public final class TableName { public static String parse(String qualifiedTableName) { return new TableName(qualifiedTableName).getName(); } - + public String toString() { return getQualifiedName(); } /** * Gets the catalog. - * + * * @return the catalog */ public String getCatalog() { @@ -79,7 +84,7 @@ public final class TableName { /** * Gets the schema. - * + * * @return the schema */ public String getSchema() { @@ -88,7 +93,7 @@ public final class TableName { /** * Gets the name. - * + * * @return the name */ public String getName() { @@ -100,7 +105,7 @@ public final class TableName { *

* Catalog and schema are optional. *

- * + * * @return the qualified name */ public String getQualifiedName() { @@ -139,13 +144,13 @@ public final class TableName { buffer.append(schema).append("."); } } - + /** * Checks if is table name is valid i.e. it has at least a name. - * + * * @return true, if is valid */ public boolean isValid() { return name != null && !name.isEmpty(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/config/UnderscoreNamingConvention.java b/src/main/java/com/avaje/ebean/config/UnderscoreNamingConvention.java index 1abe2bc28..b44c6f140 100644 --- a/src/main/java/com/avaje/ebean/config/UnderscoreNamingConvention.java +++ b/src/main/java/com/avaje/ebean/config/UnderscoreNamingConvention.java @@ -106,7 +106,7 @@ public class UnderscoreNamingConvention extends AbstractNamingConvention { protected String toUnderscoreFromCamel(String camelCase) { int lastUpper = -1; - StringBuilder sb = new StringBuilder(camelCase.length()+4); + StringBuilder sb = new StringBuilder(camelCase.length() + 4); for (int i = 0; i < camelCase.length(); i++) { char c = camelCase.charAt(i); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java index b65d1cabd..2c23a3b42 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java @@ -10,7 +10,7 @@ import java.sql.Types; * treated as though that data type can not be encrypted in the DB and will * instead use java client encryption. *

- * + * * @author rbygrave */ public abstract class AbstractDbEncrypt implements DbEncrypt { @@ -41,23 +41,23 @@ public abstract class AbstractDbEncrypt implements DbEncrypt { */ public DbEncryptFunction getDbEncryptFunction(int jdbcType) { switch (jdbcType) { - case Types.VARCHAR: - return varcharEncryptFunction; - case Types.CLOB: - return varcharEncryptFunction; - case Types.CHAR: - return varcharEncryptFunction; - case Types.LONGVARCHAR: - return varcharEncryptFunction; + case Types.VARCHAR: + return varcharEncryptFunction; + case Types.CLOB: + return varcharEncryptFunction; + case Types.CHAR: + return varcharEncryptFunction; + case Types.LONGVARCHAR: + return varcharEncryptFunction; - case Types.DATE: - return dateEncryptFunction; + case Types.DATE: + return dateEncryptFunction; - case Types.TIMESTAMP: - return timestampEncryptFunction; + case Types.TIMESTAMP: + return timestampEncryptFunction; - default: - return null; + default: + return null; } } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java index 9c0261481..ed30fa2f4 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java @@ -1,12 +1,11 @@ package com.avaje.ebean.config.dbplatform; -import java.sql.Types; - -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; import com.avaje.ebean.dbmigration.ddlgeneration.platform.DB2Ddl; +import javax.sql.DataSource; +import java.sql.Types; + /** * DB2 specific platform. */ diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DB2SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/DB2SequenceIdGenerator.java index d19e0b7c6..fdc24a0f6 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DB2SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DB2SequenceIdGenerator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.config.dbplatform; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; +import javax.sql.DataSource; + /** * DB2 specific sequence Id Generator. */ diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java index 97671b6ed..951f0fb53 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java @@ -3,6 +3,7 @@ package com.avaje.ebean.config.dbplatform; import com.avaje.ebean.BackgroundExecutor; import com.avaje.ebean.Query; import com.avaje.ebean.config.CustomDbTypeMapping; +import com.avaje.ebean.config.DbTypeConfig; import com.avaje.ebean.config.PersistBatch; import com.avaje.ebean.config.Platform; import com.avaje.ebean.config.ServerConfig; @@ -180,15 +181,27 @@ public class DatabasePlatform { /** * Configure UUID Storage etc based on ServerConfig settings. */ - public void configure(ServerConfig serverConfig) { - dbTypeMap.config(nativeUuidType, serverConfig.getDbUuid()); - for (CustomDbTypeMapping mapping : serverConfig.getCustomTypeMappings()) { + public void configure(DbTypeConfig config) { + addGeoTypes(config.getGeometrySRID()); + configureIdType(config.getIdType()); + dbTypeMap.config(nativeUuidType, config.getDbUuid()); + for (CustomDbTypeMapping mapping : config.getCustomTypeMappings()) { if (platformMatch(mapping.getPlatform())) { dbTypeMap.put(mapping.getType(), parse(mapping.getColumnDefinition())); } } } + protected void configureIdType(IdType idType) { + if (idType != null) { + this.dbIdentity.setIdType(idType); + } + } + + protected void addGeoTypes(int srid) { + // default has no geo type support + } + private DbPlatformType parse(String columnDefinition) { return DbPlatformType.parse(columnDefinition); } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java index 0a0776318..049e699bc 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java @@ -23,7 +23,7 @@ public class DbDefaultValue { */ public static final String NOW = "now"; - protected Map map = new LinkedHashMap(); + protected Map map = new LinkedHashMap<>(); /** * Set the DB now function. diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java index ab7671889..129bc2c0b 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java @@ -8,7 +8,7 @@ package com.avaje.ebean.config.dbplatform; * a special ScalarType but this has the limitation that you can't include that * property in query where clauses. *

- * + * * @author rbygrave */ public interface DbEncrypt { @@ -38,4 +38,4 @@ public interface DbEncrypt { * Return true if the DB encrypt function binds the data before the key. */ boolean isBindEncryptDataFirst(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbIdentity.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbIdentity.java index 9c20467dc..442493059 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbIdentity.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbIdentity.java @@ -135,9 +135,9 @@ public class DbIdentity { return supportsSequence ? IdType.SEQUENCE : idType; case IDENTITY: return supportsIdentity ? IdType.IDENTITY : idType; + default: + return idType; } - // use the default - return idType; } } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformType.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformType.java index c2599d7aa..aec57b745 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformType.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformType.java @@ -65,11 +65,9 @@ public class DbPlatformType implements ExtraDbTypes { /** * Use with canHaveLength=false for types that should never have a length. - * - * @param name - * the type name - * @param canHaveLength - * set this to false for type that should never have a length + * + * @param name the type name + * @param canHaveLength set this to false for type that should never have a length */ public DbPlatformType(String name, boolean canHaveLength) { this.name = name; @@ -106,12 +104,10 @@ public class DbPlatformType implements ExtraDbTypes { * The deployLength and deployScale are for the property we are rendering the * DB type for. *

- * - * @param deployLength - * the length or precision defined by deployment on a specific - * property. - * @param deployScale - * the scale defined by deployment on a specific property. + * + * @param deployLength the length or precision defined by deployment on a specific + * property. + * @param deployScale the scale defined by deployment on a specific property. */ public String renderType(int deployLength, int deployScale) { return renderType(deployLength, deployScale, true); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookup.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookup.java index 57a0b1083..ca9c39341 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookup.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookup.java @@ -11,12 +11,12 @@ class DbPlatformTypeLookup { /** * A map to lookup the type by name. */ - private Map nameLookup = new HashMap(); + private Map nameLookup = new HashMap<>(); /** * A map to lookup the type by JDBC int value. */ - private Map idLookup = new HashMap(); + private Map idLookup = new HashMap<>(); DbPlatformTypeLookup() { addAll(); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java index 8906f911a..27b90996b 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java @@ -2,7 +2,6 @@ package com.avaje.ebean.config.dbplatform; import com.avaje.ebean.config.ServerConfig; -import java.sql.Types; import java.util.HashMap; import java.util.Map; @@ -26,7 +25,7 @@ public class DbPlatformTypeMapping { private static final DbPlatformType MULTILINESTRING = new DbPlatformType("multilinestring"); private static final DbPlatformType MULTIPOLYGON = new DbPlatformType("multipolygon"); - private final Map typeMap = new HashMap(); + private final Map typeMap = new HashMap<>(); /** * Return the DbTypeMap with standard (not platform specific) types. @@ -104,7 +103,8 @@ public class DbPlatformTypeMapping { put(DbType.JSONCLOB, JSON_CLOB_PLACEHOLDER); put(DbType.JSONBLOB, JSON_BLOB_PLACEHOLDER); put(DbType.JSONVARCHAR, JSON_VARCHAR_PLACEHOLDER); - put(DbType.UUID, UUID_PLACEHOLDER); + // use reasonable default of varchar(40) - ideally set via DatabasePlatform.configure(DbTypeConfig) + put(DbType.UUID, get(DbType.VARCHAR).withLength(40)); } } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java index 589a7f8cc..8641b159e 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java @@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform; /** * H2 encryption support via encrypt decrypt function. - * + * * @author rbygrave */ public class H2DbEncrypt extends AbstractDbEncrypt { @@ -23,8 +23,7 @@ public class H2DbEncrypt extends AbstractDbEncrypt { public String getDecryptSql(String columnWithTableAlias) { // Hmmm, this looks ugly - checking with H2 Database folks. - return "TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " - + columnWithTableAlias + ")))"; + return "TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " + columnWithTableAlias + ")))"; } public String getEncryptBindSql() { @@ -36,8 +35,7 @@ public class H2DbEncrypt extends AbstractDbEncrypt { private static class H2DateFunction implements DbEncryptFunction { public String getDecryptSql(String columnWithTableAlias) { - return "PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " - + columnWithTableAlias + "))),'yyyyMMdd')"; + return "PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " + columnWithTableAlias + "))),'yyyyMMdd')"; } public String getEncryptBindSql() { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java index 25ba2073d..05d841088 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java @@ -1,11 +1,9 @@ package com.avaje.ebean.config.dbplatform; import com.avaje.ebean.BackgroundExecutor; -import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.dbmigration.ddlgeneration.platform.H2Ddl; import javax.sql.DataSource; -import java.util.Properties; /** * H2 specific platform. @@ -30,20 +28,7 @@ public class H2Platform extends DatabasePlatform { // escape clause for now noting that backslash is an escape char for like in H2 this.likeClause = "like ?"; - // H2 data types match default JDBC types - // so no changes to dbTypeMap required - } - - @Override - public void configure(ServerConfig serverConfig) { - super.configure(serverConfig); - Properties properties = serverConfig.getProperties(); - if (properties != null) { - String idType = properties.getProperty("ebean.h2.idtype"); - if (idType != null) { - this.dbIdentity.setIdType(IdType.valueOf(idType)); - } - } + dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false)); } /** diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2SequenceIdGenerator.java index 7547746f3..4b234bb8b 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/H2SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2SequenceIdGenerator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.config.dbplatform; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; +import javax.sql.DataSource; + /** * H2 specific sequence Id Generator. */ diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/LimitOffsetSqlLimiter.java b/src/main/java/com/avaje/ebean/config/dbplatform/LimitOffsetSqlLimiter.java index 1daa75286..de60acc86 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/LimitOffsetSqlLimiter.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/LimitOffsetSqlLimiter.java @@ -18,7 +18,7 @@ public class LimitOffsetSqlLimiter implements SqlLimiter { public SqlLimitResponse limit(SqlLimitRequest request) { String dbSql = request.getDbSql(); - + StringBuilder sb = new StringBuilder(50 + dbSql.length()); sb.append("select "); if (request.isDistinct()) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java index c8bf68ca2..474d06b0a 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java @@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform; /** * MySql aes_encrypt aes_decrypt based encryption support. - * + * * @author rbygrave */ public class MySqlDbEncrypt extends AbstractDbEncrypt { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/OracleDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/OracleDbEncrypt.java index 90ab9eab2..01208bf15 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/OracleDbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/OracleDbEncrypt.java @@ -2,46 +2,44 @@ package com.avaje.ebean.config.dbplatform; /** * Oracle encryption support. - * + * *

* You will typically need to create your own encryption and decryption * functions similar to the example ones below. *

- * + * *
- * 
- *  // Remember your DB user needs execute privilege on DBMS_CRYPTO 
+ *
+ *  // Remember your DB user needs execute privilege on DBMS_CRYPTO
  *  // as well as your encryption and decryption functions
- *  
- *  
+ *
+ *
  *  // This is an Example Encryption function only - please create your own.
- * 
+ *
  * CREATE OR REPLACE FUNCTION eb_encrypt(data IN VARCHAR, key in VARCHAR) RETURN RAW IS
- * 
+ *
  *     encryption_mode NUMBER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC  + DBMS_CRYPTO.PAD_PKCS5;
- * 
+ *
  *     BEGIN
- *          RETURN DBMS_CRYPTO.ENCRYPT(UTL_I18N.STRING_TO_RAW (data, 'AL32UTF8'), 
+ *          RETURN DBMS_CRYPTO.ENCRYPT(UTL_I18N.STRING_TO_RAW (data, 'AL32UTF8'),
  *            encryption_mode, UTL_I18N.STRING_TO_RAW(key, 'AL32UTF8') );
  *     END;
  *     /
- *     
- *     
- *     
+ *
+ *
+ *
  *  // This is an Example Decryption function only - please create your own.
- *     
+ *
  * CREATE OR REPLACE FUNCTION eb_decrypt(data IN RAW, key IN VARCHAR) RETURN VARCHAR IS
- * 
+ *
  *     encryption_mode NUMBER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC  + DBMS_CRYPTO.PAD_PKCS5;
- * 
+ *
  *     BEGIN
  *          RETURN UTL_RAW.CAST_TO_VARCHAR2(DBMS_CRYPTO.DECRYPT
  *            (data, encryption_mode, UTL_I18N.STRING_TO_RAW(key, 'AL32UTF8')));
  *     END;
  *     /
  * 
- * - * @author rbygrave */ public class OracleDbEncrypt extends AbstractDbEncrypt { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/OracleSequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/OracleSequenceIdGenerator.java index 52436bb30..67992900b 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/OracleSequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/OracleSequenceIdGenerator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.config.dbplatform; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; +import javax.sql.DataSource; + /** * Oracle specific sequence Id Generator. */ @@ -14,11 +14,9 @@ public class OracleSequenceIdGenerator extends SequenceIdGenerator { /** * Construct given a dataSource and sql to return the next sequence value. */ - public OracleSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, - int batchSize) { + public OracleSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) { super(be, ds, seqName, batchSize); - this.baseSql = "select " + seqName - + ".nextval, a from (select level as a FROM dual CONNECT BY level <= "; + this.baseSql = "select " + seqName + ".nextval, a from (select level as a FROM dual CONNECT BY level <= "; } public String getSql(int batchSize) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java index e74111934..ad53ef00d 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java @@ -2,8 +2,6 @@ package com.avaje.ebean.config.dbplatform; /** * Postgres pgp_sym_encrypt pgp_sym_decrypt based encryption support. - * - * @author rbygrave */ public class PostgresDbEncrypt extends AbstractDbEncrypt { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java index 18aa77446..4c66e09db 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java @@ -7,7 +7,6 @@ import com.avaje.ebean.dbmigration.ddlgeneration.platform.PostgresDdl; import javax.sql.DataSource; import java.sql.Types; -import java.util.Properties; /** * Postgres v9 specific platform. @@ -44,6 +43,7 @@ public class PostgresPlatform extends DatabasePlatform { DbPlatformType dbTypeText = new DbPlatformType("text"); DbPlatformType dbBytea = new DbPlatformType("bytea", false); + dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false)); dbTypeMap.put(DbType.HSTORE, new DbPlatformType("hstore", false)); dbTypeMap.put(DbType.JSON, new DbPlatformType("json", false)); dbTypeMap.put(DbType.JSONB, new DbPlatformType("jsonb", false)); @@ -63,31 +63,17 @@ public class PostgresPlatform extends DatabasePlatform { dbTypeMap.put(DbType.LONGVARCHAR, dbTypeText); } - @Override - public void configure(ServerConfig serverConfig) { - super.configure(serverConfig); - Properties properties = serverConfig.getProperties(); - if (properties != null) { - String tsType = properties.getProperty("ebean.postgres.timestamp"); - if (tsType != null) { - // set timestamp type to "timestamp" without time zone - dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType(tsType)); - } - } - addGeoTypes(serverConfig.getGeometrySRID()); - } - - private void addGeoTypes(int srid) { - dbTypeMap.put(DbType.POINT, geoType("point",srid)); - dbTypeMap.put(DbType.POLYGON, geoType("polygon",srid)); - dbTypeMap.put(DbType.LINESTRING, geoType("linestring",srid)); - dbTypeMap.put(DbType.MULTIPOINT, geoType("multipoint",srid)); - dbTypeMap.put(DbType.MULTILINESTRING, geoType("multilinestring",srid)); - dbTypeMap.put(DbType.MULTIPOLYGON, geoType("multipolygon",srid)); + protected void addGeoTypes(int srid) { + dbTypeMap.put(DbType.POINT, geoType("point", srid)); + dbTypeMap.put(DbType.POLYGON, geoType("polygon", srid)); + dbTypeMap.put(DbType.LINESTRING, geoType("linestring", srid)); + dbTypeMap.put(DbType.MULTIPOINT, geoType("multipoint", srid)); + dbTypeMap.put(DbType.MULTILINESTRING, geoType("multilinestring", srid)); + dbTypeMap.put(DbType.MULTIPOLYGON, geoType("multipolygon", srid)); } private DbPlatformType geoType(String type, int srid) { - return new DbPlatformType("geometry("+type+","+srid+")"); + return new DbPlatformType("geometry(" + type + "," + srid + ")"); } /** diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresSequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresSequenceIdGenerator.java index eb7af2632..20942eb0f 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresSequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresSequenceIdGenerator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.config.dbplatform; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; +import javax.sql.DataSource; + /** * Postgres specific sequence Id Generator. */ @@ -14,11 +14,9 @@ public class PostgresSequenceIdGenerator extends SequenceIdGenerator { /** * Construct given a dataSource and sql to return the next sequence value. */ - public PostgresSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, - int batchSize) { + public PostgresSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) { super(be, ds, seqName, batchSize); - this.baseSql = "select nextval('" + seqName + "'), s.generate_series from (" - + "select generate_series from generate_series(1,"; + this.baseSql = "select nextval('" + seqName + "'), s.generate_series from (select generate_series from generate_series(1,"; } public String getSql(int batchSize) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/RowNumberSqlLimiter.java b/src/main/java/com/avaje/ebean/config/dbplatform/RowNumberSqlLimiter.java index bd46b3831..43bfbcd56 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/RowNumberSqlLimiter.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/RowNumberSqlLimiter.java @@ -31,7 +31,7 @@ public class RowNumberSqlLimiter implements SqlLimiter { public SqlLimitResponse limit(SqlLimitRequest request) { String dbSql = request.getDbSql(); - + StringBuilder sb = new StringBuilder(60 + dbSql.length()); int firstRow = request.getFirstRow(); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/RownumSqlLimiter.java b/src/main/java/com/avaje/ebean/config/dbplatform/RownumSqlLimiter.java index 71fb5c99d..e24c07a19 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/RownumSqlLimiter.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/RownumSqlLimiter.java @@ -36,7 +36,7 @@ public class RownumSqlLimiter implements SqlLimiter { // where rnum >= :MIN_ROW_TO_FETCH; String dbSql = request.getDbSql(); - + StringBuilder sb = new StringBuilder(60 + dbSql.length()); int firstRow = request.getFirstRow(); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java index e0ce358ec..0f5053bca 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java @@ -1,19 +1,18 @@ package com.avaje.ebean.config.dbplatform; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; - -import javax.persistence.PersistenceException; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; import com.avaje.ebean.Transaction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + /** * Database sequence based IdGenerator. */ @@ -40,7 +39,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { protected final BackgroundExecutor backgroundExecutor; - protected final ArrayList idList = new ArrayList(50); + protected final ArrayList idList = new ArrayList<>(50); protected final int batchSize; @@ -98,11 +97,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { protected void loadLargeAllocation(final int allocateSize) { // preAllocateIds was called with a relatively large batchSize // so we will just go ahead and load those anyway in background - backgroundExecutor.execute(new Runnable() { - public void run() { - loadMoreIds(allocateSize, null); - } - }); + backgroundExecutor.execute(() -> loadMoreIds(allocateSize, null)); } /** @@ -145,12 +140,10 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { currentlyBackgroundLoading = batchSize; - backgroundExecutor.execute(new Runnable() { - public void run() { - loadMoreIds(batchSize, null); - synchronized (backgroundLoadMonitor) { - currentlyBackgroundLoading = 0; - } + backgroundExecutor.execute(() -> { + loadMoreIds(batchSize, null); + synchronized (backgroundLoadMonitor) { + currentlyBackgroundLoading = 0; } }); } @@ -165,8 +158,8 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { } synchronized (monitor) { - for (int i = 0; i < newIds.size(); i++) { - idList.add(newIds.get(i)); + for (Long newId : newIds) { + idList.add(newId); } } } @@ -178,7 +171,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { String sql = getSql(loadSize); - ArrayList newIds = new ArrayList(loadSize); + ArrayList newIds = new ArrayList<>(loadSize); boolean useTxnConnection = t != null; @@ -226,7 +219,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { rset.close(); } } catch (SQLException e) { - logger.error( "Error closing ResultSet", e); + logger.error("Error closing ResultSet", e); } try { if (pstmt != null) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SimpleSequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/SimpleSequenceIdGenerator.java index ead28d3fc..1ddbbee15 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SimpleSequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SimpleSequenceIdGenerator.java @@ -1,17 +1,16 @@ package com.avaje.ebean.config.dbplatform; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import javax.persistence.PersistenceException; -import javax.sql.DataSource; - import com.avaje.ebean.Transaction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + /** * A very simple Database sequence based IdGenerator. *

diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SqlAnywhereLimiter.java b/src/main/java/com/avaje/ebean/config/dbplatform/SqlAnywhereLimiter.java index d5e0994ab..069fa05ec 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SqlAnywhereLimiter.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SqlAnywhereLimiter.java @@ -8,7 +8,7 @@ public class SqlAnywhereLimiter implements SqlLimiter { public SqlLimitResponse limit(SqlLimitRequest request) { String dbSql = request.getDbSql(); - + StringBuilder sb = new StringBuilder(60 + dbSql.length()); int firstRow = request.getFirstRow(); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/package.html b/src/main/java/com/avaje/ebean/config/dbplatform/package.html index cf8b5e070..5e3df5b2d 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/package.html +++ b/src/main/java/com/avaje/ebean/config/dbplatform/package.html @@ -1,10 +1,10 @@ - - Database platform specific support + + Database platform specific support Database platform specific support - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/config/package.html b/src/main/java/com/avaje/ebean/config/package.html index a3be4d069..f89a304ff 100644 --- a/src/main/java/com/avaje/ebean/config/package.html +++ b/src/main/java/com/avaje/ebean/config/package.html @@ -1,10 +1,10 @@ - - Configuration settings for EbeanServer construction + + Configuration settings for EbeanServer construction Configuration settings for EbeanServer construction - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java b/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java index 06692d82c..e4fda0461 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java @@ -4,10 +4,10 @@ import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.config.DbConstraintNaming; import com.avaje.ebean.config.DbMigrationConfig; +import com.avaje.ebean.config.Platform; import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.dbplatform.DB2Platform; import com.avaje.ebean.config.dbplatform.DatabasePlatform; -import com.avaje.ebean.config.Platform; import com.avaje.ebean.config.dbplatform.H2Platform; import com.avaje.ebean.config.dbplatform.MsSqlServer2005Platform; import com.avaje.ebean.config.dbplatform.MySqlPlatform; @@ -79,7 +79,7 @@ public class DbMigration { protected DatabasePlatform databasePlatform; - protected List platforms = new ArrayList(); + protected List platforms = new ArrayList<>(); protected ServerConfig serverConfig; diff --git a/src/main/java/com/avaje/ebean/dbmigration/DdlGenerator.java b/src/main/java/com/avaje/ebean/dbmigration/DdlGenerator.java index c7426989a..2f995fce2 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/DdlGenerator.java +++ b/src/main/java/com/avaje/ebean/dbmigration/DdlGenerator.java @@ -21,7 +21,7 @@ import java.sql.SQLException; /** * Controls the generation and execution of "Create All" and "Drop All" DDL scripts. - * + *

* Typically the "Create All" DDL is executed for running tests etc and has nothing to do * with DB Migration (diff based) DDL. */ diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/DdlWrite.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/DdlWrite.java index e0a6bae94..40a8208a5 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/DdlWrite.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/DdlWrite.java @@ -60,9 +60,9 @@ public class DdlWrite { */ public boolean isApplyEmpty() { return apply.getBuffer().isEmpty() - && applyForeignKeys.getBuffer().isEmpty() - && applyHistory.getBuffer().isEmpty() - && applyDropDependencies.getBuffer().isEmpty(); + && applyForeignKeys.getBuffer().isEmpty() + && applyHistory.getBuffer().isEmpty() + && applyDropDependencies.getBuffer().isEmpty(); } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java index 94deb10d1..344ba3320 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java @@ -53,7 +53,7 @@ public class BaseTableDdl implements TableDdl { /** * Used when unique constraints specifically for OneToOne can't be created normally (MsSqlServer). */ - protected List externalUnique = new ArrayList(); + protected List externalUnique = new ArrayList<>(); // counters used when constraint names are truncated due to maximum length // and these counters are used to keep the constraint name unique @@ -66,7 +66,7 @@ public class BaseTableDdl implements TableDdl { * Base tables that have associated history tables that need their triggers/functions regenerated as * columns have been added, removed, included or excluded. */ - protected Map regenerateHistoryTriggers = new LinkedHashMap(); + protected Map regenerateHistoryTriggers = new LinkedHashMap<>(); /** * Construct with a naming convention and platform specific DDL. @@ -206,12 +206,12 @@ public class BaseTableDdl implements TableDdl { String uqName = col.getUniqueOneToOne(); String[] columnNames = {col.getName()}; write.apply() - .append(platformDdl.alterTableAddUniqueConstraint(tableName, uqName, columnNames)) - .endOfStatement(); + .append(platformDdl.alterTableAddUniqueConstraint(tableName, uqName, columnNames)) + .endOfStatement(); write.dropAllForeignKeys() - .append(platformDdl.dropIndex(uqName, tableName)) - .endOfStatement(); + .append(platformDdl.dropIndex(uqName, tableName)) + .endOfStatement(); } } @@ -338,11 +338,11 @@ public class BaseTableDdl implements TableDdl { fkeyBuffer.end(); write.dropAllForeignKeys() - .append(platformDdl.alterTableDropForeignKey(tableName, fkName)).endOfStatement(); + .append(platformDdl.alterTableDropForeignKey(tableName, fkName)).endOfStatement(); if (indexName != null) { write.dropAllForeignKeys() - .append(platformDdl.dropIndex(indexName, tableName)).endOfStatement(); + .append(platformDdl.dropIndex(indexName, tableName)).endOfStatement(); } write.dropAllForeignKeys().end(); @@ -499,7 +499,7 @@ public class BaseTableDdl implements TableDdl { * Return the list of columns that make the primary key. */ protected List determinePrimaryKeyColumns(List columns) { - List pk = new ArrayList(3); + List pk = new ArrayList<>(3); for (Column column : columns) { if (isTrue(column.isPrimaryKey())) { pk.add(column); @@ -513,20 +513,20 @@ public class BaseTableDdl implements TableDdl { String[] cols = toColumnNamesSplit(createIndex.getColumns()); writer.apply() - .append(platformDdl.createIndex(createIndex.getIndexName(), createIndex.getTableName(), cols)) - .endOfStatement(); + .append(platformDdl.createIndex(createIndex.getIndexName(), createIndex.getTableName(), cols)) + .endOfStatement(); writer.dropAll() - .append(platformDdl.dropIndex(createIndex.getIndexName(), createIndex.getTableName())) - .endOfStatement(); + .append(platformDdl.dropIndex(createIndex.getIndexName(), createIndex.getTableName())) + .endOfStatement(); } @Override public void generate(DdlWrite writer, DropIndex dropIndex) throws IOException { writer.apply() - .append(platformDdl.dropIndex(dropIndex.getIndexName(), dropIndex.getTableName())) - .endOfStatement(); + .append(platformDdl.dropIndex(dropIndex.getIndexName(), dropIndex.getTableName())) + .endOfStatement(); } /** @@ -793,16 +793,16 @@ public class BaseTableDdl implements TableDdl { protected void alterColumnDropForeignKey(DdlWrite writer, AlterColumn alter) throws IOException { writer.apply() - .append(platformDdl.alterTableDropForeignKey(alter.getTableName(), alter.getDropForeignKey())) - .endOfStatement(); + .append(platformDdl.alterTableDropForeignKey(alter.getTableName(), alter.getDropForeignKey())) + .endOfStatement(); } protected void alterColumnDropUniqueConstraint(DdlWrite writer, AlterColumn alter) throws IOException { writer.apply() - .append(platformDdl.alterTableDropUniqueConstraint(alter.getTableName(), alter.getDropUnique())) - .endOfStatement(); + .append(platformDdl.alterTableDropUniqueConstraint(alter.getTableName(), alter.getDropUnique())) + .endOfStatement(); } protected void alterColumnAddUniqueOneToOneConstraint(DdlWrite writer, AlterColumn alter) throws IOException { @@ -820,27 +820,27 @@ public class BaseTableDdl implements TableDdl { String[] cols = {alter.getColumnName()}; writer.apply() - .append(platformDdl.alterTableAddUniqueConstraint(alter.getTableName(), uqName, cols)) - .endOfStatement(); + .append(platformDdl.alterTableAddUniqueConstraint(alter.getTableName(), uqName, cols)) + .endOfStatement(); writer.dropAllForeignKeys() - .append(platformDdl.dropIndex(uqName, alter.getTableName())) - .endOfStatement(); + .append(platformDdl.dropIndex(uqName, alter.getTableName())) + .endOfStatement(); } protected void alterTableDropColumn(DdlBuffer buffer, String tableName, String columnName) throws IOException { buffer.append("alter table ").append(tableName).append(" drop column ").append(columnName) - .endOfStatement(); + .endOfStatement(); } protected void alterTableAddColumn(DdlBuffer buffer, String tableName, Column column, boolean onHistoryTable) throws IOException { String convertedType = platformDdl.convert(column.getType(), false); buffer.append("alter table ").append(tableName) - .append(" add column ").append(column.getName()) - .append(" ").append(convertedType); + .append(" add column ").append(column.getName()) + .append(" ").append(convertedType); if (!onHistoryTable) { if (isTrue(column.isNotnull())) { diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java index 4ea033ef7..9d3e844ee 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java @@ -164,9 +164,9 @@ public abstract class DbTriggerBasedHistoryDdl implements PlatformHistoryDdl { protected void addSysPeriodColumns(DdlBuffer apply, String baseTableName, String whenCreatedColumn) throws IOException { apply.append("alter table ").append(baseTableName).append(" add column ") - .append(sysPeriodStart).append(" ").append(sysPeriodType).append(" default ").append(currentTimestamp).endOfStatement(); + .append(sysPeriodStart).append(" ").append(sysPeriodType).append(" default ").append(currentTimestamp).endOfStatement(); apply.append("alter table ").append(baseTableName).append(" add column ") - .append(sysPeriodEnd).append(" ").append(sysPeriodType).endOfStatement(); + .append(sysPeriodEnd).append(" ").append(sysPeriodType).endOfStatement(); if (whenCreatedColumn != null) { apply.append("update ").append(baseTableName).append(" set ").append(sysPeriodStart).append(" = ").append(whenCreatedColumn).endOfStatement(); @@ -204,10 +204,10 @@ public abstract class DbTriggerBasedHistoryDdl implements PlatformHistoryDdl { protected void createWithHistoryView(DdlBuffer apply, String baseTableName) throws IOException { apply - .append("create view ").append(baseTableName).append(viewSuffix) - .append(" as select * from ").append(baseTableName) - .append(" union all select * from ").append(baseTableName).append(historySuffix) - .endOfStatement().end(); + .append("create view ").append(baseTableName).append(viewSuffix) + .append(" as select * from ").append(baseTableName) + .append(" union all select * from ").append(baseTableName).append(historySuffix) + .endOfStatement().end(); } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdl.java index 1072e1eba..dde2ed843 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdl.java @@ -45,8 +45,8 @@ public class H2HistoryDdl extends DbTriggerBasedHistoryDdl { // Note that this does not take into account the historyTable name (excepts _history suffix) and // does not take into account excluded columns (all columns included in history) apply - .append("create trigger ").append(triggerName).append(" before update,delete on ").append(baseTable) - .append(" for each row call \"" + TRIGGER_CLASS + "\";").newLine(); + .append("create trigger ").append(triggerName).append(" before update,delete on ").append(baseTable) + .append(" for each row call \"" + TRIGGER_CLASS + "\";").newLine(); } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java index 8f743fc91..c72e18f7a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java @@ -36,14 +36,14 @@ public class HistoryTableUpdate { } public String description() { - return change.name().toLowerCase()+" "+column; + return change.name().toLowerCase() + " " + column; } } private final String baseTable; - private final List columnChanges = new ArrayList(); + private final List columnChanges = new ArrayList<>(); /** * Construct with a given base table name. diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java index 64902be84..73eca28c5 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java @@ -37,7 +37,7 @@ public class MsSqlServerDdl extends PlatformDdl { public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns) { // issues#233 - String start = "create unique nonclustered index " + uqName + " on " + tableName+ "("; + String start = "create unique nonclustered index " + uqName + " on " + tableName + "("; StringBuilder sb = new StringBuilder(start); for (int i = 0; i < columns.length; i++) { @@ -47,8 +47,8 @@ public class MsSqlServerDdl extends PlatformDdl { sb.append(columns[i]); } sb.append(") where"); - for (int i = 0; i < columns.length; i++) { - sb.append(" ").append(columns[i]).append(" is not null"); + for (String column : columns) { + sb.append(" ").append(column).append(" is not null"); } return sb.toString(); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlDdl.java index 545b5ba43..df23acd9d 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlDdl.java @@ -15,7 +15,7 @@ public class MySqlDdl extends PlatformDdl { public MySqlDdl(DatabasePlatform platform) { super(platform); - this.alterColumn = "modify"; + this.alterColumn = "modify"; this.dropUniqueConstraint = "drop index"; this.historyDdl = new MySqlHistoryDdl(); this.inlineComments = true; diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlHistoryDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlHistoryDdl.java index 9de3ccf49..81f727a66 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlHistoryDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlHistoryDdl.java @@ -48,22 +48,22 @@ public class MySqlHistoryDdl extends DbTriggerBasedHistoryDdl { DdlBuffer apply = update.historyBuffer(); apply - .append("delimiter $$").newLine() - .append("create trigger ").append(triggerName).append(" before update on ").append(update.getBaseTable()) - .append(" for each row begin").newLine(); + .append("delimiter $$").newLine() + .append("create trigger ").append(triggerName).append(" before update on ").append(update.getBaseTable()) + .append(" for each row begin").newLine(); appendInsertIntoHistory(apply, update.getHistoryTable(), update.getColumns()); apply - .append(" set NEW.").append(sysPeriod).append("_start = now(6)").endOfStatement() - .append("end$$").newLine(); + .append(" set NEW.").append(sysPeriod).append("_start = now(6)").endOfStatement() + .append("end$$").newLine(); } private void addBeforeDelete(String triggerName, DbTriggerUpdate update) throws IOException { DdlBuffer apply = update.historyBuffer(); apply - .append("delimiter $$").newLine() - .append("create trigger ").append(triggerName).append(" before delete on ").append(update.getBaseTable()) - .append(" for each row begin").newLine(); + .append("delimiter $$").newLine() + .append("create trigger ").append(triggerName).append(" before delete on ").append(update.getBaseTable()) + .append(" for each row begin").newLine(); appendInsertIntoHistory(apply, update.getHistoryTable(), update.getColumns()); apply.append("end$$").newLine(); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/Oracle10Ddl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/Oracle10Ddl.java index c4f93b8f9..8037459fe 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/Oracle10Ddl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/Oracle10Ddl.java @@ -15,7 +15,7 @@ public class Oracle10Ddl extends PlatformDdl { this.dropIndexIfExists = "drop index "; this.dropTableCascade = " cascade constraints purge"; this.foreignKeyRestrict = ""; - this.alterColumn = "modify"; + this.alterColumn = "modify"; this.columnSetNotnull = "not null"; this.columnSetNull = "null"; this.columnSetDefault = "default"; diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java index 460300bf6..6e177483c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java @@ -320,13 +320,13 @@ public class PlatformDdl { StringBuilder buffer = new StringBuilder(90); buffer - .append("alter table ").append(tableName) - .append(" add constraint ").append(fkName) - .append(" foreign key"); + .append("alter table ").append(tableName) + .append(" add constraint ").append(fkName) + .append(" foreign key"); appendColumns(columns, buffer); buffer - .append(" references ") - .append(lowerTableName(refTable)); + .append(" references ") + .append(lowerTableName(refTable)); appendColumns(refColumns, buffer); appendWithSpace(foreignKeyRestrict, buffer); diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresHistoryDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresHistoryDdl.java index 037756905..ccb026e8c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresHistoryDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresHistoryDdl.java @@ -25,8 +25,8 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl { String baseTable = table.getName(); apply - .append("create table ").append(baseTable).append(historySuffix) - .append("(like ").append(baseTable).append(")").endOfStatement(); + .append("create table ").append(baseTable).append(historySuffix) + .append("(like ").append(baseTable).append(")").endOfStatement(); } /** @@ -35,13 +35,13 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl { @Override protected void addSysPeriodColumns(DdlBuffer apply, String baseTableName, String whenCreatedColumn) throws IOException { apply - .append("alter table ").append(baseTableName) - .append(" add column ").append(sysPeriod).append(" tstzrange not null default tstzrange(").append(currentTimestamp).append(", null)") - .endOfStatement(); + .append("alter table ").append(baseTableName) + .append(" add column ").append(sysPeriod).append(" tstzrange not null default tstzrange(").append(currentTimestamp).append(", null)") + .endOfStatement(); if (whenCreatedColumn != null) { apply.append("update ").append(baseTableName).append(" set ") - .append(sysPeriod).append(" = tstzrange(").append(whenCreatedColumn).append(", null)").endOfStatement(); + .append(sysPeriod).append(" = tstzrange(").append(whenCreatedColumn).append(", null)").endOfStatement(); } } @@ -64,9 +64,9 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl { DdlBuffer apply = writer.applyHistory(); apply - .append("create trigger ").append(triggerName).newLine() - .append(" before update or delete on ").append(baseTableName).newLine() - .append(" for each row execute procedure ").append(procedureName).append("();").newLine().newLine(); + .append("create trigger ").append(triggerName).newLine() + .append(" before update or delete on ").append(baseTableName).newLine() + .append(" for each row execute procedure ").append(procedureName).append("();").newLine().newLine(); } @Override @@ -79,23 +79,23 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl { protected void createOrReplaceFunction(DdlBuffer apply, String procedureName, String historyTable, List includedColumns) throws IOException { apply - .append("create or replace function ").append(procedureName).append("() returns trigger as $$").newLine() - .append("begin").newLine(); + .append("create or replace function ").append(procedureName).append("() returns trigger as $$").newLine() + .append("begin").newLine(); apply - .append(" if (TG_OP = 'UPDATE') then").newLine(); + .append(" if (TG_OP = 'UPDATE') then").newLine(); appendInsertIntoHistory(apply, historyTable, includedColumns); apply - .append(" NEW.").append(sysPeriod).append(" = tstzrange(").append(currentTimestamp).append(",null);").newLine() - .append(" return new;").newLine(); + .append(" NEW.").append(sysPeriod).append(" = tstzrange(").append(currentTimestamp).append(",null);").newLine() + .append(" return new;").newLine(); apply - .append(" elsif (TG_OP = 'DELETE') then").newLine(); + .append(" elsif (TG_OP = 'DELETE') then").newLine(); appendInsertIntoHistory(apply, historyTable, includedColumns); apply - .append(" return old;").newLine(); + .append(" return old;").newLine(); apply - .append(" end if;").newLine() - .append("end;").newLine() - .append("$$ LANGUAGE plpgsql;").newLine(); + .append(" end if;").newLine() + .append("end;").newLine() + .append("$$ LANGUAGE plpgsql;").newLine(); apply.end(); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java index f0475f468..bc99b0701 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java @@ -1,6 +1,7 @@ package com.avaje.ebean.dbmigration.ddlgeneration.platform.util; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -8,7 +9,7 @@ import java.util.List; */ public class IndexColumns { - List columns = new ArrayList(4); + List columns = new ArrayList<>(4); /** * Construct representing as a single column index. @@ -21,9 +22,7 @@ public class IndexColumns { * Construct representing index. */ public IndexColumns(String[] columnNames) { - for (int i = 0; i < columnNames.length; i++) { - columns.add(columnNames[i]); - } + Collections.addAll(columns, columnNames); } /** @@ -40,7 +39,7 @@ public class IndexColumns { if (columns.size() != columnNames.size()) { return false; } - for (int i = 0; i indexes = new ArrayList(); + private List indexes = new ArrayList<>(); /** * Clear the indexes (for each table). @@ -36,8 +36,8 @@ public class IndexSet { */ public boolean add(String[] columns) { IndexColumns newIndex = new IndexColumns(columns); - for (int i = 0; i < indexes.size(); i++) { - if (indexes.get(i).isMatch(newIndex)) { + for (IndexColumns indexe : indexes) { + if (indexe.isMatch(newIndex)) { return false; } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AddColumn.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AddColumn.java index 58de889a3..9392fbc29 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AddColumn.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AddColumn.java @@ -1,21 +1,20 @@ - package com.avaje.ebean.dbmigration.migration; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -29,98 +28,86 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "column" + "column" }) @XmlRootElement(name = "addColumn") public class AddColumn { - @XmlElement(required = true) - protected List column; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "withHistory") - protected Boolean withHistory; + @XmlElement(required = true) + protected List column; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "withHistory") + protected Boolean withHistory; - /** - * Gets the value of the column property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the column property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getColumn().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Column } - * - * - */ - public List getColumn() { - if (column == null) { - column = new ArrayList(); - } - return this.column; + /** + * Gets the value of the column property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the column property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getColumn().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Column } + */ + public List getColumn() { + if (column == null) { + column = new ArrayList<>(); } + return this.column; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the withHistory property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isWithHistory() { - return withHistory; - } + /** + * Gets the value of the withHistory property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isWithHistory() { + return withHistory; + } - /** - * Sets the value of the withHistory property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setWithHistory(Boolean value) { - this.withHistory = value; - } + /** + * Sets the value of the withHistory property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setWithHistory(Boolean value) { + this.withHistory = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AddHistoryTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AddHistoryTable.java index 1ea167f4e..d48f1ae9a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AddHistoryTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AddHistoryTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -22,39 +21,33 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "addHistoryTable") public class AddHistoryTable { - @XmlAttribute(name = "baseTable", required = true) - protected String baseTable; + @XmlAttribute(name = "baseTable", required = true) + protected String baseTable; - /** - * Gets the value of the baseTable property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBaseTable() { - return baseTable; - } + /** + * Gets the value of the baseTable property. + * + * @return possible object is + * {@link String } + */ + public String getBaseTable() { + return baseTable; + } - /** - * Sets the value of the baseTable property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBaseTable(String value) { - this.baseTable = value; - } + /** + * Sets the value of the baseTable property. + * + * @param value allowed object is + * {@link String } + */ + public void setBaseTable(String value) { + this.baseTable = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AddTableComment.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AddTableComment.java index 40d50c625..a5e81e26e 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AddTableComment.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AddTableComment.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "addTableComment") public class AddTableComment { - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "comment", required = true) - protected String comment; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "comment", required = true) + protected String comment; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AlterColumn.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AlterColumn.java index 7f8c683ca..a0676e33e 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AlterColumn.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AlterColumn.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -43,585 +42,495 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "alterColumn") public class AlterColumn { - @XmlAttribute(name = "columnName", required = true) - protected String columnName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "withHistory") - protected Boolean withHistory; - @XmlAttribute(name = "type") - protected String type; - @XmlAttribute(name = "currentType") - protected String currentType; - @XmlAttribute(name = "defaultValue") - protected String defaultValue; - @XmlAttribute(name = "currentDefaultValue") - protected String currentDefaultValue; - @XmlAttribute(name = "notnull") - protected Boolean notnull; - @XmlAttribute(name = "currentNotnull") - protected Boolean currentNotnull; - @XmlAttribute(name = "comment") - protected String comment; - @XmlAttribute(name = "historyExclude") - protected Boolean historyExclude; - @XmlAttribute(name = "checkConstraint") - protected String checkConstraint; - @XmlAttribute(name = "checkConstraintName") - protected String checkConstraintName; - @XmlAttribute(name = "dropCheckConstraint") - protected String dropCheckConstraint; - @XmlAttribute(name = "unique") - protected String unique; - @XmlAttribute(name = "uniqueOneToOne") - protected String uniqueOneToOne; - @XmlAttribute(name = "dropUnique") - protected String dropUnique; - @XmlAttribute(name = "references") - protected String references; - @XmlAttribute(name = "foreignKeyName") - protected String foreignKeyName; - @XmlAttribute(name = "foreignKeyIndex") - protected String foreignKeyIndex; - @XmlAttribute(name = "dropForeignKey") - protected String dropForeignKey; - @XmlAttribute(name = "dropForeignKeyIndex") - protected String dropForeignKeyIndex; + @XmlAttribute(name = "columnName", required = true) + protected String columnName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "withHistory") + protected Boolean withHistory; + @XmlAttribute(name = "type") + protected String type; + @XmlAttribute(name = "currentType") + protected String currentType; + @XmlAttribute(name = "defaultValue") + protected String defaultValue; + @XmlAttribute(name = "currentDefaultValue") + protected String currentDefaultValue; + @XmlAttribute(name = "notnull") + protected Boolean notnull; + @XmlAttribute(name = "currentNotnull") + protected Boolean currentNotnull; + @XmlAttribute(name = "comment") + protected String comment; + @XmlAttribute(name = "historyExclude") + protected Boolean historyExclude; + @XmlAttribute(name = "checkConstraint") + protected String checkConstraint; + @XmlAttribute(name = "checkConstraintName") + protected String checkConstraintName; + @XmlAttribute(name = "dropCheckConstraint") + protected String dropCheckConstraint; + @XmlAttribute(name = "unique") + protected String unique; + @XmlAttribute(name = "uniqueOneToOne") + protected String uniqueOneToOne; + @XmlAttribute(name = "dropUnique") + protected String dropUnique; + @XmlAttribute(name = "references") + protected String references; + @XmlAttribute(name = "foreignKeyName") + protected String foreignKeyName; + @XmlAttribute(name = "foreignKeyIndex") + protected String foreignKeyIndex; + @XmlAttribute(name = "dropForeignKey") + protected String dropForeignKey; + @XmlAttribute(name = "dropForeignKeyIndex") + protected String dropForeignKeyIndex; - /** - * Gets the value of the columnName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumnName() { - return columnName; - } + /** + * Gets the value of the columnName property. + * + * @return possible object is + * {@link String } + */ + public String getColumnName() { + return columnName; + } - /** - * Sets the value of the columnName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumnName(String value) { - this.columnName = value; - } + /** + * Sets the value of the columnName property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumnName(String value) { + this.columnName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the withHistory property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isWithHistory() { - return withHistory; - } + /** + * Gets the value of the withHistory property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isWithHistory() { + return withHistory; + } - /** - * Sets the value of the withHistory property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setWithHistory(Boolean value) { - this.withHistory = value; - } + /** + * Sets the value of the withHistory property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setWithHistory(Boolean value) { + this.withHistory = value; + } - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link String } + */ + public void setType(String value) { + this.type = value; + } - /** - * Gets the value of the currentType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCurrentType() { - return currentType; - } + /** + * Gets the value of the currentType property. + * + * @return possible object is + * {@link String } + */ + public String getCurrentType() { + return currentType; + } - /** - * Sets the value of the currentType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCurrentType(String value) { - this.currentType = value; - } + /** + * Sets the value of the currentType property. + * + * @param value allowed object is + * {@link String } + */ + public void setCurrentType(String value) { + this.currentType = value; + } - /** - * Gets the value of the defaultValue property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDefaultValue() { - return defaultValue; - } + /** + * Gets the value of the defaultValue property. + * + * @return possible object is + * {@link String } + */ + public String getDefaultValue() { + return defaultValue; + } - /** - * Sets the value of the defaultValue property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDefaultValue(String value) { - this.defaultValue = value; - } + /** + * Sets the value of the defaultValue property. + * + * @param value allowed object is + * {@link String } + */ + public void setDefaultValue(String value) { + this.defaultValue = value; + } - /** - * Gets the value of the currentDefaultValue property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCurrentDefaultValue() { - return currentDefaultValue; - } + /** + * Gets the value of the currentDefaultValue property. + * + * @return possible object is + * {@link String } + */ + public String getCurrentDefaultValue() { + return currentDefaultValue; + } - /** - * Sets the value of the currentDefaultValue property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCurrentDefaultValue(String value) { - this.currentDefaultValue = value; - } + /** + * Sets the value of the currentDefaultValue property. + * + * @param value allowed object is + * {@link String } + */ + public void setCurrentDefaultValue(String value) { + this.currentDefaultValue = value; + } - /** - * Gets the value of the notnull property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isNotnull() { - return notnull; - } + /** + * Gets the value of the notnull property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isNotnull() { + return notnull; + } - /** - * Sets the value of the notnull property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setNotnull(Boolean value) { - this.notnull = value; - } + /** + * Sets the value of the notnull property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setNotnull(Boolean value) { + this.notnull = value; + } - /** - * Gets the value of the currentNotnull property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isCurrentNotnull() { - return currentNotnull; - } + /** + * Gets the value of the currentNotnull property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isCurrentNotnull() { + return currentNotnull; + } - /** - * Sets the value of the currentNotnull property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setCurrentNotnull(Boolean value) { - this.currentNotnull = value; - } + /** + * Sets the value of the currentNotnull property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setCurrentNotnull(Boolean value) { + this.currentNotnull = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } - /** - * Gets the value of the historyExclude property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isHistoryExclude() { - return historyExclude; - } + /** + * Gets the value of the historyExclude property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isHistoryExclude() { + return historyExclude; + } - /** - * Sets the value of the historyExclude property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setHistoryExclude(Boolean value) { - this.historyExclude = value; - } + /** + * Sets the value of the historyExclude property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setHistoryExclude(Boolean value) { + this.historyExclude = value; + } - /** - * Gets the value of the checkConstraint property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCheckConstraint() { - return checkConstraint; - } + /** + * Gets the value of the checkConstraint property. + * + * @return possible object is + * {@link String } + */ + public String getCheckConstraint() { + return checkConstraint; + } - /** - * Sets the value of the checkConstraint property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCheckConstraint(String value) { - this.checkConstraint = value; - } + /** + * Sets the value of the checkConstraint property. + * + * @param value allowed object is + * {@link String } + */ + public void setCheckConstraint(String value) { + this.checkConstraint = value; + } - /** - * Gets the value of the checkConstraintName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCheckConstraintName() { - return checkConstraintName; - } + /** + * Gets the value of the checkConstraintName property. + * + * @return possible object is + * {@link String } + */ + public String getCheckConstraintName() { + return checkConstraintName; + } - /** - * Sets the value of the checkConstraintName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCheckConstraintName(String value) { - this.checkConstraintName = value; - } + /** + * Sets the value of the checkConstraintName property. + * + * @param value allowed object is + * {@link String } + */ + public void setCheckConstraintName(String value) { + this.checkConstraintName = value; + } - /** - * Gets the value of the dropCheckConstraint property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropCheckConstraint() { - return dropCheckConstraint; - } + /** + * Gets the value of the dropCheckConstraint property. + * + * @return possible object is + * {@link String } + */ + public String getDropCheckConstraint() { + return dropCheckConstraint; + } - /** - * Sets the value of the dropCheckConstraint property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropCheckConstraint(String value) { - this.dropCheckConstraint = value; - } + /** + * Sets the value of the dropCheckConstraint property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropCheckConstraint(String value) { + this.dropCheckConstraint = value; + } - /** - * Gets the value of the unique property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUnique() { - return unique; - } + /** + * Gets the value of the unique property. + * + * @return possible object is + * {@link String } + */ + public String getUnique() { + return unique; + } - /** - * Sets the value of the unique property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setUnique(String value) { - this.unique = value; - } + /** + * Sets the value of the unique property. + * + * @param value allowed object is + * {@link String } + */ + public void setUnique(String value) { + this.unique = value; + } - /** - * Gets the value of the uniqueOneToOne property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUniqueOneToOne() { - return uniqueOneToOne; - } + /** + * Gets the value of the uniqueOneToOne property. + * + * @return possible object is + * {@link String } + */ + public String getUniqueOneToOne() { + return uniqueOneToOne; + } - /** - * Sets the value of the uniqueOneToOne property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setUniqueOneToOne(String value) { - this.uniqueOneToOne = value; - } + /** + * Sets the value of the uniqueOneToOne property. + * + * @param value allowed object is + * {@link String } + */ + public void setUniqueOneToOne(String value) { + this.uniqueOneToOne = value; + } - /** - * Gets the value of the dropUnique property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropUnique() { - return dropUnique; - } + /** + * Gets the value of the dropUnique property. + * + * @return possible object is + * {@link String } + */ + public String getDropUnique() { + return dropUnique; + } - /** - * Sets the value of the dropUnique property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropUnique(String value) { - this.dropUnique = value; - } + /** + * Sets the value of the dropUnique property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropUnique(String value) { + this.dropUnique = value; + } - /** - * Gets the value of the references property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReferences() { - return references; - } + /** + * Gets the value of the references property. + * + * @return possible object is + * {@link String } + */ + public String getReferences() { + return references; + } - /** - * Sets the value of the references property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReferences(String value) { - this.references = value; - } + /** + * Sets the value of the references property. + * + * @param value allowed object is + * {@link String } + */ + public void setReferences(String value) { + this.references = value; + } - /** - * Gets the value of the foreignKeyName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getForeignKeyName() { - return foreignKeyName; - } + /** + * Gets the value of the foreignKeyName property. + * + * @return possible object is + * {@link String } + */ + public String getForeignKeyName() { + return foreignKeyName; + } - /** - * Sets the value of the foreignKeyName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setForeignKeyName(String value) { - this.foreignKeyName = value; - } + /** + * Sets the value of the foreignKeyName property. + * + * @param value allowed object is + * {@link String } + */ + public void setForeignKeyName(String value) { + this.foreignKeyName = value; + } - /** - * Gets the value of the foreignKeyIndex property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getForeignKeyIndex() { - return foreignKeyIndex; - } + /** + * Gets the value of the foreignKeyIndex property. + * + * @return possible object is + * {@link String } + */ + public String getForeignKeyIndex() { + return foreignKeyIndex; + } - /** - * Sets the value of the foreignKeyIndex property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setForeignKeyIndex(String value) { - this.foreignKeyIndex = value; - } + /** + * Sets the value of the foreignKeyIndex property. + * + * @param value allowed object is + * {@link String } + */ + public void setForeignKeyIndex(String value) { + this.foreignKeyIndex = value; + } - /** - * Gets the value of the dropForeignKey property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropForeignKey() { - return dropForeignKey; - } + /** + * Gets the value of the dropForeignKey property. + * + * @return possible object is + * {@link String } + */ + public String getDropForeignKey() { + return dropForeignKey; + } - /** - * Sets the value of the dropForeignKey property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropForeignKey(String value) { - this.dropForeignKey = value; - } + /** + * Sets the value of the dropForeignKey property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropForeignKey(String value) { + this.dropForeignKey = value; + } - /** - * Gets the value of the dropForeignKeyIndex property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropForeignKeyIndex() { - return dropForeignKeyIndex; - } + /** + * Gets the value of the dropForeignKeyIndex property. + * + * @return possible object is + * {@link String } + */ + public String getDropForeignKeyIndex() { + return dropForeignKeyIndex; + } - /** - * Sets the value of the dropForeignKeyIndex property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropForeignKeyIndex(String value) { - this.dropForeignKeyIndex = value; - } + /** + * Sets the value of the dropForeignKeyIndex property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropForeignKeyIndex(String value) { + this.dropForeignKeyIndex = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AlterHistoryTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AlterHistoryTable.java index e57b52add..431188bdc 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AlterHistoryTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AlterHistoryTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -22,39 +21,33 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "alterHistoryTable") public class AlterHistoryTable { - @XmlAttribute(name = "baseTable", required = true) - protected String baseTable; + @XmlAttribute(name = "baseTable", required = true) + protected String baseTable; - /** - * Gets the value of the baseTable property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBaseTable() { - return baseTable; - } + /** + * Gets the value of the baseTable property. + * + * @return possible object is + * {@link String } + */ + public String getBaseTable() { + return baseTable; + } - /** - * Sets the value of the baseTable property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBaseTable(String value) { - this.baseTable = value; - } + /** + * Sets the value of the baseTable property. + * + * @param value allowed object is + * {@link String } + */ + public void setBaseTable(String value) { + this.baseTable = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Application.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Application.java index 31b8a130c..2063ffaf6 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Application.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Application.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "application") public class Application { - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "resourcePath", required = true) - protected String resourcePath; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "resourcePath", required = true) + protected String resourcePath; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the resourcePath property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getResourcePath() { - return resourcePath; - } + /** + * Gets the value of the resourcePath property. + * + * @return possible object is + * {@link String } + */ + public String getResourcePath() { + return resourcePath; + } - /** - * Sets the value of the resourcePath property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setResourcePath(String value) { - this.resourcePath = value; - } + /** + * Sets the value of the resourcePath property. + * + * @param value allowed object is + * {@link String } + */ + public void setResourcePath(String value) { + this.resourcePath = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java index 3c6b52774..68c898b31 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java @@ -1,19 +1,18 @@ - package com.avaje.ebean.dbmigration.migration; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,45 +24,41 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "application" + "application" }) @XmlRootElement(name = "applications") public class Applications { - protected List application; + protected List application; - /** - * Gets the value of the application property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the application property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getApplication().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Application } - * - * - */ - public List getApplication() { - if (application == null) { - application = new ArrayList(); - } - return this.application; + /** + * Gets the value of the application property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the application property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getApplication().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Application } + */ + public List getApplication() { + if (application == null) { + application = new ArrayList<>(); } + return this.application; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Apply.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Apply.java index 3ca1a3fca..b43954ace 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Apply.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Apply.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <simpleContent>
@@ -21,41 +20,35 @@ import javax.xml.bind.annotation.XmlValue;
  *   </simpleContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "value" + "value" }) @XmlRootElement(name = "apply") public class Apply { - @XmlValue - protected String value; + @XmlValue + protected String value; - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() { + return value; + } - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) { + this.value = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java index 8341525c5..6ed514c10 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java @@ -1,8 +1,5 @@ - package com.avaje.ebean.dbmigration.migration; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -10,13 +7,15 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -36,230 +35,202 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "changeSetChildren" + "changeSetChildren" }) @XmlRootElement(name = "changeSet") public class ChangeSet { - @XmlElements({ - @XmlElement(name = "configuration", type = Configuration.class), - @XmlElement(name = "sql", type = Sql.class), - @XmlElement(name = "createTable", type = CreateTable.class), - @XmlElement(name = "dropTable", type = DropTable.class), - @XmlElement(name = "renameTable", type = RenameTable.class), - @XmlElement(name = "addTableComment", type = AddTableComment.class), - @XmlElement(name = "addHistoryTable", type = AddHistoryTable.class), - @XmlElement(name = "dropHistoryTable", type = DropHistoryTable.class), - @XmlElement(name = "addColumn", type = AddColumn.class), - @XmlElement(name = "dropColumn", type = DropColumn.class), - @XmlElement(name = "alterColumn", type = AlterColumn.class), - @XmlElement(name = "renameColumn", type = RenameColumn.class), - @XmlElement(name = "createIndex", type = CreateIndex.class), - @XmlElement(name = "dropIndex", type = DropIndex.class) - }) - protected List changeSetChildren; - @XmlAttribute(name = "type", required = true) - protected ChangeSetType type; - @XmlAttribute(name = "dropsFor") - protected String dropsFor; - @XmlAttribute(name = "suppressDropsForever") - protected Boolean suppressDropsForever; - @XmlAttribute(name = "generated") - protected Boolean generated; - @XmlAttribute(name = "author") - protected String author; - @XmlAttribute(name = "comment") - protected String comment; + @XmlElements({ + @XmlElement(name = "configuration", type = Configuration.class), + @XmlElement(name = "sql", type = Sql.class), + @XmlElement(name = "createTable", type = CreateTable.class), + @XmlElement(name = "dropTable", type = DropTable.class), + @XmlElement(name = "renameTable", type = RenameTable.class), + @XmlElement(name = "addTableComment", type = AddTableComment.class), + @XmlElement(name = "addHistoryTable", type = AddHistoryTable.class), + @XmlElement(name = "dropHistoryTable", type = DropHistoryTable.class), + @XmlElement(name = "addColumn", type = AddColumn.class), + @XmlElement(name = "dropColumn", type = DropColumn.class), + @XmlElement(name = "alterColumn", type = AlterColumn.class), + @XmlElement(name = "renameColumn", type = RenameColumn.class), + @XmlElement(name = "createIndex", type = CreateIndex.class), + @XmlElement(name = "dropIndex", type = DropIndex.class) + }) + protected List changeSetChildren; + @XmlAttribute(name = "type", required = true) + protected ChangeSetType type; + @XmlAttribute(name = "dropsFor") + protected String dropsFor; + @XmlAttribute(name = "suppressDropsForever") + protected Boolean suppressDropsForever; + @XmlAttribute(name = "generated") + protected Boolean generated; + @XmlAttribute(name = "author") + protected String author; + @XmlAttribute(name = "comment") + protected String comment; - /** - * Gets the value of the changeSetChildren property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the changeSetChildren property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getChangeSetChildren().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Configuration } - * {@link Sql } - * {@link CreateTable } - * {@link DropTable } - * {@link RenameTable } - * {@link AddTableComment } - * {@link AddHistoryTable } - * {@link DropHistoryTable } - * {@link AddColumn } - * {@link DropColumn } - * {@link AlterColumn } - * {@link RenameColumn } - * {@link CreateIndex } - * {@link DropIndex } - * - * - */ - public List getChangeSetChildren() { - if (changeSetChildren == null) { - changeSetChildren = new ArrayList(); - } - return this.changeSetChildren; + /** + * Gets the value of the changeSetChildren property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the changeSetChildren property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getChangeSetChildren().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Configuration } + * {@link Sql } + * {@link CreateTable } + * {@link DropTable } + * {@link RenameTable } + * {@link AddTableComment } + * {@link AddHistoryTable } + * {@link DropHistoryTable } + * {@link AddColumn } + * {@link DropColumn } + * {@link AlterColumn } + * {@link RenameColumn } + * {@link CreateIndex } + * {@link DropIndex } + */ + public List getChangeSetChildren() { + if (changeSetChildren == null) { + changeSetChildren = new ArrayList<>(); } + return this.changeSetChildren; + } - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link ChangeSetType } - * - */ - public ChangeSetType getType() { - return type; - } + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link ChangeSetType } + */ + public ChangeSetType getType() { + return type; + } - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link ChangeSetType } - * - */ - public void setType(ChangeSetType value) { - this.type = value; - } + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link ChangeSetType } + */ + public void setType(ChangeSetType value) { + this.type = value; + } - /** - * Gets the value of the dropsFor property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropsFor() { - return dropsFor; - } + /** + * Gets the value of the dropsFor property. + * + * @return possible object is + * {@link String } + */ + public String getDropsFor() { + return dropsFor; + } - /** - * Sets the value of the dropsFor property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropsFor(String value) { - this.dropsFor = value; - } + /** + * Sets the value of the dropsFor property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropsFor(String value) { + this.dropsFor = value; + } - /** - * Gets the value of the suppressDropsForever property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isSuppressDropsForever() { - return suppressDropsForever; - } + /** + * Gets the value of the suppressDropsForever property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isSuppressDropsForever() { + return suppressDropsForever; + } - /** - * Sets the value of the suppressDropsForever property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setSuppressDropsForever(Boolean value) { - this.suppressDropsForever = value; - } + /** + * Sets the value of the suppressDropsForever property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setSuppressDropsForever(Boolean value) { + this.suppressDropsForever = value; + } - /** - * Gets the value of the generated property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isGenerated() { - return generated; - } + /** + * Gets the value of the generated property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isGenerated() { + return generated; + } - /** - * Sets the value of the generated property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setGenerated(Boolean value) { - this.generated = value; - } + /** + * Sets the value of the generated property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setGenerated(Boolean value) { + this.generated = value; + } - /** - * Gets the value of the author property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAuthor() { - return author; - } + /** + * Gets the value of the author property. + * + * @return possible object is + * {@link String } + */ + public String getAuthor() { + return author; + } - /** - * Sets the value of the author property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAuthor(String value) { - this.author = value; - } + /** + * Sets the value of the author property. + * + * @param value allowed object is + * {@link String } + */ + public void setAuthor(String value) { + this.author = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSetType.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSetType.java index b87dffebb..b7708a362 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSetType.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSetType.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlEnum; @@ -8,7 +7,7 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for changeSetType. - * + *

*

The following schema fragment specifies the expected content contained within this class. *

*

@@ -20,35 +19,34 @@ import javax.xml.bind.annotation.XmlType;
  *   </restriction>
  * </simpleType>
  * 
- * */ @XmlType(name = "changeSetType") @XmlEnum public enum ChangeSetType { - @XmlEnumValue("apply") - APPLY("apply"), - @XmlEnumValue("pendingDrops") - PENDING_DROPS("pendingDrops"), - @XmlEnumValue("baseline") - BASELINE("baseline"); - private final String value; + @XmlEnumValue("apply") + APPLY("apply"), + @XmlEnumValue("pendingDrops") + PENDING_DROPS("pendingDrops"), + @XmlEnumValue("baseline") + BASELINE("baseline"); + private final String value; - ChangeSetType(String v) { - value = v; - } + ChangeSetType(String v) { + value = v; + } - public String value() { - return value; - } + public String value() { + return value; + } - public static ChangeSetType fromValue(String v) { - for (ChangeSetType c: ChangeSetType.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); + public static ChangeSetType fromValue(String v) { + for (ChangeSetType c : ChangeSetType.values()) { + if (c.value.equals(v)) { + return c; + } } + throw new IllegalArgumentException(v); + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Column.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Column.java index e99569ebe..2e2aecfc7 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Column.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Column.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -11,9 +10,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -37,431 +36,365 @@ import javax.xml.bind.annotation.XmlValue;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "content" + "content" }) @XmlRootElement(name = "column") public class Column { - @XmlValue - protected String content; - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "type", required = true) - protected String type; - @XmlAttribute(name = "defaultValue") - protected String defaultValue; - @XmlAttribute(name = "notnull") - protected Boolean notnull; - @XmlAttribute(name = "historyExclude") - protected Boolean historyExclude; - @XmlAttribute(name = "primaryKey") - protected Boolean primaryKey; - @XmlAttribute(name = "identity") - protected Boolean identity; - @XmlAttribute(name = "checkConstraint") - protected String checkConstraint; - @XmlAttribute(name = "checkConstraintName") - protected String checkConstraintName; - @XmlAttribute(name = "unique") - protected String unique; - @XmlAttribute(name = "uniqueOneToOne") - protected String uniqueOneToOne; - @XmlAttribute(name = "references") - protected String references; - @XmlAttribute(name = "foreignKeyName") - protected String foreignKeyName; - @XmlAttribute(name = "foreignKeyIndex") - protected String foreignKeyIndex; - @XmlAttribute(name = "comment") - protected String comment; + @XmlValue + protected String content; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "type", required = true) + protected String type; + @XmlAttribute(name = "defaultValue") + protected String defaultValue; + @XmlAttribute(name = "notnull") + protected Boolean notnull; + @XmlAttribute(name = "historyExclude") + protected Boolean historyExclude; + @XmlAttribute(name = "primaryKey") + protected Boolean primaryKey; + @XmlAttribute(name = "identity") + protected Boolean identity; + @XmlAttribute(name = "checkConstraint") + protected String checkConstraint; + @XmlAttribute(name = "checkConstraintName") + protected String checkConstraintName; + @XmlAttribute(name = "unique") + protected String unique; + @XmlAttribute(name = "uniqueOneToOne") + protected String uniqueOneToOne; + @XmlAttribute(name = "references") + protected String references; + @XmlAttribute(name = "foreignKeyName") + protected String foreignKeyName; + @XmlAttribute(name = "foreignKeyIndex") + protected String foreignKeyIndex; + @XmlAttribute(name = "comment") + protected String comment; - /** - * Gets the value of the content property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getContent() { - return content; - } + /** + * Gets the value of the content property. + * + * @return possible object is + * {@link String } + */ + public String getContent() { + return content; + } - /** - * Sets the value of the content property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setContent(String value) { - this.content = value; - } + /** + * Sets the value of the content property. + * + * @param value allowed object is + * {@link String } + */ + public void setContent(String value) { + this.content = value; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link String } + */ + public void setType(String value) { + this.type = value; + } - /** - * Gets the value of the defaultValue property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDefaultValue() { - return defaultValue; - } + /** + * Gets the value of the defaultValue property. + * + * @return possible object is + * {@link String } + */ + public String getDefaultValue() { + return defaultValue; + } - /** - * Sets the value of the defaultValue property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDefaultValue(String value) { - this.defaultValue = value; - } + /** + * Sets the value of the defaultValue property. + * + * @param value allowed object is + * {@link String } + */ + public void setDefaultValue(String value) { + this.defaultValue = value; + } - /** - * Gets the value of the notnull property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isNotnull() { - return notnull; - } + /** + * Gets the value of the notnull property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isNotnull() { + return notnull; + } - /** - * Sets the value of the notnull property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setNotnull(Boolean value) { - this.notnull = value; - } + /** + * Sets the value of the notnull property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setNotnull(Boolean value) { + this.notnull = value; + } - /** - * Gets the value of the historyExclude property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isHistoryExclude() { - return historyExclude; - } + /** + * Gets the value of the historyExclude property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isHistoryExclude() { + return historyExclude; + } - /** - * Sets the value of the historyExclude property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setHistoryExclude(Boolean value) { - this.historyExclude = value; - } + /** + * Sets the value of the historyExclude property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setHistoryExclude(Boolean value) { + this.historyExclude = value; + } - /** - * Gets the value of the primaryKey property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isPrimaryKey() { - return primaryKey; - } + /** + * Gets the value of the primaryKey property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isPrimaryKey() { + return primaryKey; + } - /** - * Sets the value of the primaryKey property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setPrimaryKey(Boolean value) { - this.primaryKey = value; - } + /** + * Sets the value of the primaryKey property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setPrimaryKey(Boolean value) { + this.primaryKey = value; + } - /** - * Gets the value of the identity property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isIdentity() { - return identity; - } + /** + * Gets the value of the identity property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isIdentity() { + return identity; + } - /** - * Sets the value of the identity property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setIdentity(Boolean value) { - this.identity = value; - } + /** + * Sets the value of the identity property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setIdentity(Boolean value) { + this.identity = value; + } - /** - * Gets the value of the checkConstraint property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCheckConstraint() { - return checkConstraint; - } + /** + * Gets the value of the checkConstraint property. + * + * @return possible object is + * {@link String } + */ + public String getCheckConstraint() { + return checkConstraint; + } - /** - * Sets the value of the checkConstraint property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCheckConstraint(String value) { - this.checkConstraint = value; - } + /** + * Sets the value of the checkConstraint property. + * + * @param value allowed object is + * {@link String } + */ + public void setCheckConstraint(String value) { + this.checkConstraint = value; + } - /** - * Gets the value of the checkConstraintName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCheckConstraintName() { - return checkConstraintName; - } + /** + * Gets the value of the checkConstraintName property. + * + * @return possible object is + * {@link String } + */ + public String getCheckConstraintName() { + return checkConstraintName; + } - /** - * Sets the value of the checkConstraintName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCheckConstraintName(String value) { - this.checkConstraintName = value; - } + /** + * Sets the value of the checkConstraintName property. + * + * @param value allowed object is + * {@link String } + */ + public void setCheckConstraintName(String value) { + this.checkConstraintName = value; + } - /** - * Gets the value of the unique property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUnique() { - return unique; - } + /** + * Gets the value of the unique property. + * + * @return possible object is + * {@link String } + */ + public String getUnique() { + return unique; + } - /** - * Sets the value of the unique property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setUnique(String value) { - this.unique = value; - } + /** + * Sets the value of the unique property. + * + * @param value allowed object is + * {@link String } + */ + public void setUnique(String value) { + this.unique = value; + } - /** - * Gets the value of the uniqueOneToOne property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUniqueOneToOne() { - return uniqueOneToOne; - } + /** + * Gets the value of the uniqueOneToOne property. + * + * @return possible object is + * {@link String } + */ + public String getUniqueOneToOne() { + return uniqueOneToOne; + } - /** - * Sets the value of the uniqueOneToOne property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setUniqueOneToOne(String value) { - this.uniqueOneToOne = value; - } + /** + * Sets the value of the uniqueOneToOne property. + * + * @param value allowed object is + * {@link String } + */ + public void setUniqueOneToOne(String value) { + this.uniqueOneToOne = value; + } - /** - * Gets the value of the references property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReferences() { - return references; - } + /** + * Gets the value of the references property. + * + * @return possible object is + * {@link String } + */ + public String getReferences() { + return references; + } - /** - * Sets the value of the references property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReferences(String value) { - this.references = value; - } + /** + * Sets the value of the references property. + * + * @param value allowed object is + * {@link String } + */ + public void setReferences(String value) { + this.references = value; + } - /** - * Gets the value of the foreignKeyName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getForeignKeyName() { - return foreignKeyName; - } + /** + * Gets the value of the foreignKeyName property. + * + * @return possible object is + * {@link String } + */ + public String getForeignKeyName() { + return foreignKeyName; + } - /** - * Sets the value of the foreignKeyName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setForeignKeyName(String value) { - this.foreignKeyName = value; - } + /** + * Sets the value of the foreignKeyName property. + * + * @param value allowed object is + * {@link String } + */ + public void setForeignKeyName(String value) { + this.foreignKeyName = value; + } - /** - * Gets the value of the foreignKeyIndex property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getForeignKeyIndex() { - return foreignKeyIndex; - } + /** + * Gets the value of the foreignKeyIndex property. + * + * @return possible object is + * {@link String } + */ + public String getForeignKeyIndex() { + return foreignKeyIndex; + } - /** - * Sets the value of the foreignKeyIndex property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setForeignKeyIndex(String value) { - this.foreignKeyIndex = value; - } + /** + * Sets the value of the foreignKeyIndex property. + * + * @param value allowed object is + * {@link String } + */ + public void setForeignKeyIndex(String value) { + this.foreignKeyIndex = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Configuration.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Configuration.java index 54c2c3162..9fe8c3f57 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Configuration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Configuration.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -24,41 +23,35 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "defaultTablespace" + "defaultTablespace" }) @XmlRootElement(name = "configuration") public class Configuration { - @XmlElement(required = true) - protected DefaultTablespace defaultTablespace; + @XmlElement(required = true) + protected DefaultTablespace defaultTablespace; - /** - * Gets the value of the defaultTablespace property. - * - * @return - * possible object is - * {@link DefaultTablespace } - * - */ - public DefaultTablespace getDefaultTablespace() { - return defaultTablespace; - } + /** + * Gets the value of the defaultTablespace property. + * + * @return possible object is + * {@link DefaultTablespace } + */ + public DefaultTablespace getDefaultTablespace() { + return defaultTablespace; + } - /** - * Sets the value of the defaultTablespace property. - * - * @param value - * allowed object is - * {@link DefaultTablespace } - * - */ - public void setDefaultTablespace(DefaultTablespace value) { - this.defaultTablespace = value; - } + /** + * Sets the value of the defaultTablespace property. + * + * @param value allowed object is + * {@link DefaultTablespace } + */ + public void setDefaultTablespace(DefaultTablespace value) { + this.defaultTablespace = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateIndex.java b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateIndex.java index 0a17ea99b..efdebd503 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateIndex.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateIndex.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -24,91 +23,77 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "createIndex") public class CreateIndex { - @XmlAttribute(name = "indexName", required = true) - protected String indexName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "columns", required = true) - protected String columns; + @XmlAttribute(name = "indexName", required = true) + protected String indexName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "columns", required = true) + protected String columns; - /** - * Gets the value of the indexName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexName() { - return indexName; - } + /** + * Gets the value of the indexName property. + * + * @return possible object is + * {@link String } + */ + public String getIndexName() { + return indexName; + } - /** - * Sets the value of the indexName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexName(String value) { - this.indexName = value; - } + /** + * Sets the value of the indexName property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexName(String value) { + this.indexName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the columns property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumns() { - return columns; - } + /** + * Gets the value of the columns property. + * + * @return possible object is + * {@link String } + */ + public String getColumns() { + return columns; + } - /** - * Sets the value of the columns property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumns(String value) { - this.columns = value; - } + /** + * Sets the value of the columns property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumns(String value) { + this.columns = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java index dac8198b0..58012e99c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java @@ -1,9 +1,5 @@ - package com.avaje.ebean.dbmigration.migration; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -11,13 +7,16 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -40,396 +39,344 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "column", - "uniqueConstraint", - "foreignKey" + "column", + "uniqueConstraint", + "foreignKey" }) @XmlRootElement(name = "createTable") public class CreateTable { - @XmlElement(required = true) - protected List column; - protected List uniqueConstraint; - protected List foreignKey; - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "withHistory") - protected Boolean withHistory; - @XmlAttribute(name = "draft") - protected Boolean draft; - @XmlAttribute(name = "identityType") - protected IdentityType identityType; - @XmlAttribute(name = "sequenceName") - protected String sequenceName; - @XmlAttribute(name = "sequenceInitial") - @XmlSchemaType(name = "positiveInteger") - protected BigInteger sequenceInitial; - @XmlAttribute(name = "sequenceAllocate") - @XmlSchemaType(name = "positiveInteger") - protected BigInteger sequenceAllocate; - @XmlAttribute(name = "pkName") - protected String pkName; - @XmlAttribute(name = "tablespace") - protected String tablespace; - @XmlAttribute(name = "indexTablespace") - protected String indexTablespace; - @XmlAttribute(name = "comment") - protected String comment; + @XmlElement(required = true) + protected List column; + protected List uniqueConstraint; + protected List foreignKey; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "withHistory") + protected Boolean withHistory; + @XmlAttribute(name = "draft") + protected Boolean draft; + @XmlAttribute(name = "identityType") + protected IdentityType identityType; + @XmlAttribute(name = "sequenceName") + protected String sequenceName; + @XmlAttribute(name = "sequenceInitial") + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequenceInitial; + @XmlAttribute(name = "sequenceAllocate") + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequenceAllocate; + @XmlAttribute(name = "pkName") + protected String pkName; + @XmlAttribute(name = "tablespace") + protected String tablespace; + @XmlAttribute(name = "indexTablespace") + protected String indexTablespace; + @XmlAttribute(name = "comment") + protected String comment; - /** - * Gets the value of the column property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the column property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getColumn().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Column } - * - * - */ - public List getColumn() { - if (column == null) { - column = new ArrayList(); - } - return this.column; + /** + * Gets the value of the column property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the column property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getColumn().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Column } + */ + public List getColumn() { + if (column == null) { + column = new ArrayList<>(); } + return this.column; + } - /** - * Gets the value of the uniqueConstraint property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the uniqueConstraint property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getUniqueConstraint().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link UniqueConstraint } - * - * - */ - public List getUniqueConstraint() { - if (uniqueConstraint == null) { - uniqueConstraint = new ArrayList(); - } - return this.uniqueConstraint; + /** + * Gets the value of the uniqueConstraint property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the uniqueConstraint property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getUniqueConstraint().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link UniqueConstraint } + */ + public List getUniqueConstraint() { + if (uniqueConstraint == null) { + uniqueConstraint = new ArrayList<>(); } + return this.uniqueConstraint; + } - /** - * Gets the value of the foreignKey property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the foreignKey property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getForeignKey().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link ForeignKey } - * - * - */ - public List getForeignKey() { - if (foreignKey == null) { - foreignKey = new ArrayList(); - } - return this.foreignKey; + /** + * Gets the value of the foreignKey property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the foreignKey property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getForeignKey().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link ForeignKey } + */ + public List getForeignKey() { + if (foreignKey == null) { + foreignKey = new ArrayList<>(); } + return this.foreignKey; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the withHistory property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isWithHistory() { - return withHistory; - } + /** + * Gets the value of the withHistory property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isWithHistory() { + return withHistory; + } - /** - * Sets the value of the withHistory property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setWithHistory(Boolean value) { - this.withHistory = value; - } + /** + * Sets the value of the withHistory property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setWithHistory(Boolean value) { + this.withHistory = value; + } - /** - * Gets the value of the draft property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isDraft() { - return draft; - } + /** + * Gets the value of the draft property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isDraft() { + return draft; + } - /** - * Sets the value of the draft property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setDraft(Boolean value) { - this.draft = value; - } + /** + * Sets the value of the draft property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setDraft(Boolean value) { + this.draft = value; + } - /** - * Gets the value of the identityType property. - * - * @return - * possible object is - * {@link IdentityType } - * - */ - public IdentityType getIdentityType() { - return identityType; - } + /** + * Gets the value of the identityType property. + * + * @return possible object is + * {@link IdentityType } + */ + public IdentityType getIdentityType() { + return identityType; + } - /** - * Sets the value of the identityType property. - * - * @param value - * allowed object is - * {@link IdentityType } - * - */ - public void setIdentityType(IdentityType value) { - this.identityType = value; - } + /** + * Sets the value of the identityType property. + * + * @param value allowed object is + * {@link IdentityType } + */ + public void setIdentityType(IdentityType value) { + this.identityType = value; + } - /** - * Gets the value of the sequenceName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSequenceName() { - return sequenceName; - } + /** + * Gets the value of the sequenceName property. + * + * @return possible object is + * {@link String } + */ + public String getSequenceName() { + return sequenceName; + } - /** - * Sets the value of the sequenceName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSequenceName(String value) { - this.sequenceName = value; - } + /** + * Sets the value of the sequenceName property. + * + * @param value allowed object is + * {@link String } + */ + public void setSequenceName(String value) { + this.sequenceName = value; + } - /** - * Gets the value of the sequenceInitial property. - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getSequenceInitial() { - return sequenceInitial; - } + /** + * Gets the value of the sequenceInitial property. + * + * @return possible object is + * {@link BigInteger } + */ + public BigInteger getSequenceInitial() { + return sequenceInitial; + } - /** - * Sets the value of the sequenceInitial property. - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setSequenceInitial(BigInteger value) { - this.sequenceInitial = value; - } + /** + * Sets the value of the sequenceInitial property. + * + * @param value allowed object is + * {@link BigInteger } + */ + public void setSequenceInitial(BigInteger value) { + this.sequenceInitial = value; + } - /** - * Gets the value of the sequenceAllocate property. - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getSequenceAllocate() { - return sequenceAllocate; - } + /** + * Gets the value of the sequenceAllocate property. + * + * @return possible object is + * {@link BigInteger } + */ + public BigInteger getSequenceAllocate() { + return sequenceAllocate; + } - /** - * Sets the value of the sequenceAllocate property. - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setSequenceAllocate(BigInteger value) { - this.sequenceAllocate = value; - } + /** + * Sets the value of the sequenceAllocate property. + * + * @param value allowed object is + * {@link BigInteger } + */ + public void setSequenceAllocate(BigInteger value) { + this.sequenceAllocate = value; + } - /** - * Gets the value of the pkName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPkName() { - return pkName; - } + /** + * Gets the value of the pkName property. + * + * @return possible object is + * {@link String } + */ + public String getPkName() { + return pkName; + } - /** - * Sets the value of the pkName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPkName(String value) { - this.pkName = value; - } + /** + * Sets the value of the pkName property. + * + * @param value allowed object is + * {@link String } + */ + public void setPkName(String value) { + this.pkName = value; + } - /** - * Gets the value of the tablespace property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTablespace() { - return tablespace; - } + /** + * Gets the value of the tablespace property. + * + * @return possible object is + * {@link String } + */ + public String getTablespace() { + return tablespace; + } - /** - * Sets the value of the tablespace property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTablespace(String value) { - this.tablespace = value; - } + /** + * Sets the value of the tablespace property. + * + * @param value allowed object is + * {@link String } + */ + public void setTablespace(String value) { + this.tablespace = value; + } - /** - * Gets the value of the indexTablespace property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexTablespace() { - return indexTablespace; - } + /** + * Gets the value of the indexTablespace property. + * + * @return possible object is + * {@link String } + */ + public String getIndexTablespace() { + return indexTablespace; + } - /** - * Sets the value of the indexTablespace property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexTablespace(String value) { - this.indexTablespace = value; - } + /** + * Sets the value of the indexTablespace property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexTablespace(String value) { + this.indexTablespace = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DefaultTablespace.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DefaultTablespace.java index 5beaf7555..f90124787 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DefaultTablespace.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DefaultTablespace.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -24,91 +23,77 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "defaultTablespace") public class DefaultTablespace { - @XmlAttribute(name = "tables") - protected String tables; - @XmlAttribute(name = "indexes") - protected String indexes; - @XmlAttribute(name = "history") - protected String history; + @XmlAttribute(name = "tables") + protected String tables; + @XmlAttribute(name = "indexes") + protected String indexes; + @XmlAttribute(name = "history") + protected String history; - /** - * Gets the value of the tables property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTables() { - return tables; - } + /** + * Gets the value of the tables property. + * + * @return possible object is + * {@link String } + */ + public String getTables() { + return tables; + } - /** - * Sets the value of the tables property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTables(String value) { - this.tables = value; - } + /** + * Sets the value of the tables property. + * + * @param value allowed object is + * {@link String } + */ + public void setTables(String value) { + this.tables = value; + } - /** - * Gets the value of the indexes property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexes() { - return indexes; - } + /** + * Gets the value of the indexes property. + * + * @return possible object is + * {@link String } + */ + public String getIndexes() { + return indexes; + } - /** - * Sets the value of the indexes property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexes(String value) { - this.indexes = value; - } + /** + * Sets the value of the indexes property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexes(String value) { + this.indexes = value; + } - /** - * Gets the value of the history property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getHistory() { - return history; - } + /** + * Gets the value of the history property. + * + * @return possible object is + * {@link String } + */ + public String getHistory() { + return history; + } - /** - * Sets the value of the history property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setHistory(String value) { - this.history = value; - } + /** + * Sets the value of the history property. + * + * @param value allowed object is + * {@link String } + */ + public void setHistory(String value) { + this.history = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DropColumn.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DropColumn.java index 03d42b2bf..f4c9d1ae2 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DropColumn.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DropColumn.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -24,91 +23,77 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "dropColumn") public class DropColumn { - @XmlAttribute(name = "columnName", required = true) - protected String columnName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "withHistory") - protected Boolean withHistory; + @XmlAttribute(name = "columnName", required = true) + protected String columnName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "withHistory") + protected Boolean withHistory; - /** - * Gets the value of the columnName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumnName() { - return columnName; - } + /** + * Gets the value of the columnName property. + * + * @return possible object is + * {@link String } + */ + public String getColumnName() { + return columnName; + } - /** - * Sets the value of the columnName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumnName(String value) { - this.columnName = value; - } + /** + * Sets the value of the columnName property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumnName(String value) { + this.columnName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the withHistory property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isWithHistory() { - return withHistory; - } + /** + * Gets the value of the withHistory property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isWithHistory() { + return withHistory; + } - /** - * Sets the value of the withHistory property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setWithHistory(Boolean value) { - this.withHistory = value; - } + /** + * Sets the value of the withHistory property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setWithHistory(Boolean value) { + this.withHistory = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DropHistoryTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DropHistoryTable.java index e2ad3f4b8..e50ba686c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DropHistoryTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DropHistoryTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -22,39 +21,33 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "dropHistoryTable") public class DropHistoryTable { - @XmlAttribute(name = "baseTable", required = true) - protected String baseTable; + @XmlAttribute(name = "baseTable", required = true) + protected String baseTable; - /** - * Gets the value of the baseTable property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBaseTable() { - return baseTable; - } + /** + * Gets the value of the baseTable property. + * + * @return possible object is + * {@link String } + */ + public String getBaseTable() { + return baseTable; + } - /** - * Sets the value of the baseTable property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBaseTable(String value) { - this.baseTable = value; - } + /** + * Sets the value of the baseTable property. + * + * @param value allowed object is + * {@link String } + */ + public void setBaseTable(String value) { + this.baseTable = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DropIndex.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DropIndex.java index 14e97d3a2..c3ffeb583 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DropIndex.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DropIndex.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "dropIndex") public class DropIndex { - @XmlAttribute(name = "indexName", required = true) - protected String indexName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; + @XmlAttribute(name = "indexName", required = true) + protected String indexName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; - /** - * Gets the value of the indexName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexName() { - return indexName; - } + /** + * Gets the value of the indexName property. + * + * @return possible object is + * {@link String } + */ + public String getIndexName() { + return indexName; + } - /** - * Sets the value of the indexName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexName(String value) { - this.indexName = value; - } + /** + * Sets the value of the indexName property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexName(String value) { + this.indexName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DropTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DropTable.java index fe24e36af..47330c14b 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DropTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DropTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -22,39 +21,33 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "dropTable") public class DropTable { - @XmlAttribute(name = "name", required = true) - protected String name; + @XmlAttribute(name = "name", required = true) + protected String name; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java index 7963c73d6..63a1f1ea2 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,143 +25,121 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "foreignKey") public class ForeignKey { - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "columnNames", required = true) - protected String columnNames; - @XmlAttribute(name = "refColumnNames", required = true) - protected String refColumnNames; - @XmlAttribute(name = "refTableName", required = true) - protected String refTableName; - @XmlAttribute(name = "indexName") - protected String indexName; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "columnNames", required = true) + protected String columnNames; + @XmlAttribute(name = "refColumnNames", required = true) + protected String refColumnNames; + @XmlAttribute(name = "refTableName", required = true) + protected String refTableName; + @XmlAttribute(name = "indexName") + protected String indexName; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the columnNames property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumnNames() { - return columnNames; - } + /** + * Gets the value of the columnNames property. + * + * @return possible object is + * {@link String } + */ + public String getColumnNames() { + return columnNames; + } - /** - * Sets the value of the columnNames property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumnNames(String value) { - this.columnNames = value; - } + /** + * Sets the value of the columnNames property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumnNames(String value) { + this.columnNames = value; + } - /** - * Gets the value of the refColumnNames property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRefColumnNames() { - return refColumnNames; - } + /** + * Gets the value of the refColumnNames property. + * + * @return possible object is + * {@link String } + */ + public String getRefColumnNames() { + return refColumnNames; + } - /** - * Sets the value of the refColumnNames property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRefColumnNames(String value) { - this.refColumnNames = value; - } + /** + * Sets the value of the refColumnNames property. + * + * @param value allowed object is + * {@link String } + */ + public void setRefColumnNames(String value) { + this.refColumnNames = value; + } - /** - * Gets the value of the refTableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRefTableName() { - return refTableName; - } + /** + * Gets the value of the refTableName property. + * + * @return possible object is + * {@link String } + */ + public String getRefTableName() { + return refTableName; + } - /** - * Sets the value of the refTableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRefTableName(String value) { - this.refTableName = value; - } + /** + * Sets the value of the refTableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setRefTableName(String value) { + this.refTableName = value; + } - /** - * Gets the value of the indexName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexName() { - return indexName; - } + /** + * Gets the value of the indexName property. + * + * @return possible object is + * {@link String } + */ + public String getIndexName() { + return indexName; + } - /** - * Sets the value of the indexName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexName(String value) { - this.indexName = value; - } + /** + * Sets the value of the indexName property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexName(String value) { + this.indexName = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/IdentityType.java b/src/main/java/com/avaje/ebean/dbmigration/migration/IdentityType.java index 042346cc8..97b2a542a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/IdentityType.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/IdentityType.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlEnum; @@ -8,7 +7,7 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for identityType. - * + *

*

The following schema fragment specifies the expected content contained within this class. *

*

@@ -22,39 +21,38 @@ import javax.xml.bind.annotation.XmlType;
  *   </restriction>
  * </simpleType>
  * 
- * */ @XmlType(name = "identityType") @XmlEnum public enum IdentityType { - @XmlEnumValue("identity") - IDENTITY("identity"), - @XmlEnumValue("sequence") - SEQUENCE("sequence"), - @XmlEnumValue("generator") - GENERATOR("generator"), - @XmlEnumValue("external") - EXTERNAL("external"), - @XmlEnumValue("default") - DEFAULT("default"); - private final String value; + @XmlEnumValue("identity") + IDENTITY("identity"), + @XmlEnumValue("sequence") + SEQUENCE("sequence"), + @XmlEnumValue("generator") + GENERATOR("generator"), + @XmlEnumValue("external") + EXTERNAL("external"), + @XmlEnumValue("default") + DEFAULT("default"); + private final String value; - IdentityType(String v) { - value = v; - } + IdentityType(String v) { + value = v; + } - public String value() { - return value; - } + public String value() { + return value; + } - public static IdentityType fromValue(String v) { - for (IdentityType c: IdentityType.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); + public static IdentityType fromValue(String v) { + for (IdentityType c : IdentityType.values()) { + if (c.value.equals(v)) { + return c; + } } + throw new IllegalArgumentException(v); + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java index 54f97dcb7..0277a79c0 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java @@ -1,20 +1,19 @@ - package com.avaje.ebean.dbmigration.migration; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,46 +25,42 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "changeSet" + "changeSet" }) @XmlRootElement(name = "migration") public class Migration { - @XmlElement(required = true) - protected List changeSet; + @XmlElement(required = true) + protected List changeSet; - /** - * Gets the value of the changeSet property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the changeSet property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getChangeSet().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link ChangeSet } - * - * - */ - public List getChangeSet() { - if (changeSet == null) { - changeSet = new ArrayList(); - } - return this.changeSet; + /** + * Gets the value of the changeSet property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the changeSet property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getChangeSet().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link ChangeSet } + */ + public List getChangeSet() { + if (changeSet == null) { + changeSet = new ArrayList<>(); } + return this.changeSet; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java index 632e62006..0f064b3a6 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java @@ -1,216 +1,190 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.avaje.ebean.dbmigration.migration package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.avaje.ebean.dbmigration.migration package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * */ @XmlRegistry public class ObjectFactory { - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebean.dbmigration.migration - * - */ - public ObjectFactory() { - } + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebean.dbmigration.migration + */ + public ObjectFactory() { + } - /** - * Create an instance of {@link Rollback } - * - */ - public Rollback createRollback() { - return new Rollback(); - } + /** + * Create an instance of {@link Rollback } + */ + public Rollback createRollback() { + return new Rollback(); + } - /** - * Create an instance of {@link AddColumn } - * - */ - public AddColumn createAddColumn() { - return new AddColumn(); - } + /** + * Create an instance of {@link AddColumn } + */ + public AddColumn createAddColumn() { + return new AddColumn(); + } - /** - * Create an instance of {@link Column } - * - */ - public Column createColumn() { - return new Column(); - } + /** + * Create an instance of {@link Column } + */ + public Column createColumn() { + return new Column(); + } - /** - * Create an instance of {@link CreateTable } - * - */ - public CreateTable createCreateTable() { - return new CreateTable(); - } + /** + * Create an instance of {@link CreateTable } + */ + public CreateTable createCreateTable() { + return new CreateTable(); + } - /** - * Create an instance of {@link UniqueConstraint } - * - */ - public UniqueConstraint createUniqueConstraint() { - return new UniqueConstraint(); - } + /** + * Create an instance of {@link UniqueConstraint } + */ + public UniqueConstraint createUniqueConstraint() { + return new UniqueConstraint(); + } - /** - * Create an instance of {@link ForeignKey } - * - */ - public ForeignKey createForeignKey() { - return new ForeignKey(); - } + /** + * Create an instance of {@link ForeignKey } + */ + public ForeignKey createForeignKey() { + return new ForeignKey(); + } - /** - * Create an instance of {@link Apply } - * - */ - public Apply createApply() { - return new Apply(); - } + /** + * Create an instance of {@link Apply } + */ + public Apply createApply() { + return new Apply(); + } - /** - * Create an instance of {@link Configuration } - * - */ - public Configuration createConfiguration() { - return new Configuration(); - } + /** + * Create an instance of {@link Configuration } + */ + public Configuration createConfiguration() { + return new Configuration(); + } - /** - * Create an instance of {@link DefaultTablespace } - * - */ - public DefaultTablespace createDefaultTablespace() { - return new DefaultTablespace(); - } + /** + * Create an instance of {@link DefaultTablespace } + */ + public DefaultTablespace createDefaultTablespace() { + return new DefaultTablespace(); + } - /** - * Create an instance of {@link AddTableComment } - * - */ - public AddTableComment createAddTableComment() { - return new AddTableComment(); - } + /** + * Create an instance of {@link AddTableComment } + */ + public AddTableComment createAddTableComment() { + return new AddTableComment(); + } - /** - * Create an instance of {@link RenameTable } - * - */ - public RenameTable createRenameTable() { - return new RenameTable(); - } + /** + * Create an instance of {@link RenameTable } + */ + public RenameTable createRenameTable() { + return new RenameTable(); + } - /** - * Create an instance of {@link DropHistoryTable } - * - */ - public DropHistoryTable createDropHistoryTable() { - return new DropHistoryTable(); - } + /** + * Create an instance of {@link DropHistoryTable } + */ + public DropHistoryTable createDropHistoryTable() { + return new DropHistoryTable(); + } - /** - * Create an instance of {@link AlterColumn } - * - */ - public AlterColumn createAlterColumn() { - return new AlterColumn(); - } + /** + * Create an instance of {@link AlterColumn } + */ + public AlterColumn createAlterColumn() { + return new AlterColumn(); + } - /** - * Create an instance of {@link DropColumn } - * - */ - public DropColumn createDropColumn() { - return new DropColumn(); - } + /** + * Create an instance of {@link DropColumn } + */ + public DropColumn createDropColumn() { + return new DropColumn(); + } - /** - * Create an instance of {@link CreateIndex } - * - */ - public CreateIndex createCreateIndex() { - return new CreateIndex(); - } + /** + * Create an instance of {@link CreateIndex } + */ + public CreateIndex createCreateIndex() { + return new CreateIndex(); + } - /** - * Create an instance of {@link ChangeSet } - * - */ - public ChangeSet createChangeSet() { - return new ChangeSet(); - } + /** + * Create an instance of {@link ChangeSet } + */ + public ChangeSet createChangeSet() { + return new ChangeSet(); + } - /** - * Create an instance of {@link Sql } - * - */ - public Sql createSql() { - return new Sql(); - } + /** + * Create an instance of {@link Sql } + */ + public Sql createSql() { + return new Sql(); + } - /** - * Create an instance of {@link DropTable } - * - */ - public DropTable createDropTable() { - return new DropTable(); - } + /** + * Create an instance of {@link DropTable } + */ + public DropTable createDropTable() { + return new DropTable(); + } - /** - * Create an instance of {@link AddHistoryTable } - * - */ - public AddHistoryTable createAddHistoryTable() { - return new AddHistoryTable(); - } + /** + * Create an instance of {@link AddHistoryTable } + */ + public AddHistoryTable createAddHistoryTable() { + return new AddHistoryTable(); + } - /** - * Create an instance of {@link RenameColumn } - * - */ - public RenameColumn createRenameColumn() { - return new RenameColumn(); - } + /** + * Create an instance of {@link RenameColumn } + */ + public RenameColumn createRenameColumn() { + return new RenameColumn(); + } - /** - * Create an instance of {@link DropIndex } - * - */ - public DropIndex createDropIndex() { - return new DropIndex(); - } + /** + * Create an instance of {@link DropIndex } + */ + public DropIndex createDropIndex() { + return new DropIndex(); + } - /** - * Create an instance of {@link AlterHistoryTable } - * - */ - public AlterHistoryTable createAlterHistoryTable() { - return new AlterHistoryTable(); - } + /** + * Create an instance of {@link AlterHistoryTable } + */ + public AlterHistoryTable createAlterHistoryTable() { + return new AlterHistoryTable(); + } - /** - * Create an instance of {@link Migration } - * - */ - public Migration createMigration() { - return new Migration(); - } + /** + * Create an instance of {@link Migration } + */ + public Migration createMigration() { + return new Migration(); + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/RenameColumn.java b/src/main/java/com/avaje/ebean/dbmigration/migration/RenameColumn.java index 00e1b30f4..0b9711f51 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/RenameColumn.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/RenameColumn.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,117 +24,99 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "renameColumn") public class RenameColumn { - @XmlAttribute(name = "oldName", required = true) - protected String oldName; - @XmlAttribute(name = "newName", required = true) - protected String newName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "dataType") - protected String dataType; + @XmlAttribute(name = "oldName", required = true) + protected String oldName; + @XmlAttribute(name = "newName", required = true) + protected String newName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "dataType") + protected String dataType; - /** - * Gets the value of the oldName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOldName() { - return oldName; - } + /** + * Gets the value of the oldName property. + * + * @return possible object is + * {@link String } + */ + public String getOldName() { + return oldName; + } - /** - * Sets the value of the oldName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOldName(String value) { - this.oldName = value; - } + /** + * Sets the value of the oldName property. + * + * @param value allowed object is + * {@link String } + */ + public void setOldName(String value) { + this.oldName = value; + } - /** - * Gets the value of the newName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNewName() { - return newName; - } + /** + * Gets the value of the newName property. + * + * @return possible object is + * {@link String } + */ + public String getNewName() { + return newName; + } - /** - * Sets the value of the newName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNewName(String value) { - this.newName = value; - } + /** + * Sets the value of the newName property. + * + * @param value allowed object is + * {@link String } + */ + public void setNewName(String value) { + this.newName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the dataType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDataType() { - return dataType; - } + /** + * Gets the value of the dataType property. + * + * @return possible object is + * {@link String } + */ + public String getDataType() { + return dataType; + } - /** - * Sets the value of the dataType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDataType(String value) { - this.dataType = value; - } + /** + * Sets the value of the dataType property. + * + * @param value allowed object is + * {@link String } + */ + public void setDataType(String value) { + this.dataType = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/RenameTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/RenameTable.java index aca4f7f88..3a4c83623 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/RenameTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/RenameTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "renameTable") public class RenameTable { - @XmlAttribute(name = "oldName", required = true) - protected String oldName; - @XmlAttribute(name = "newName", required = true) - protected String newName; + @XmlAttribute(name = "oldName", required = true) + protected String oldName; + @XmlAttribute(name = "newName", required = true) + protected String newName; - /** - * Gets the value of the oldName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOldName() { - return oldName; - } + /** + * Gets the value of the oldName property. + * + * @return possible object is + * {@link String } + */ + public String getOldName() { + return oldName; + } - /** - * Sets the value of the oldName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOldName(String value) { - this.oldName = value; - } + /** + * Sets the value of the oldName property. + * + * @param value allowed object is + * {@link String } + */ + public void setOldName(String value) { + this.oldName = value; + } - /** - * Gets the value of the newName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNewName() { - return newName; - } + /** + * Gets the value of the newName property. + * + * @return possible object is + * {@link String } + */ + public String getNewName() { + return newName; + } - /** - * Sets the value of the newName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNewName(String value) { - this.newName = value; - } + /** + * Sets the value of the newName property. + * + * @param value allowed object is + * {@link String } + */ + public void setNewName(String value) { + this.newName = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Rollback.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Rollback.java index 9779712a9..3d9c18d32 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Rollback.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Rollback.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <simpleContent>
@@ -21,41 +20,35 @@ import javax.xml.bind.annotation.XmlValue;
  *   </simpleContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "value" + "value" }) @XmlRootElement(name = "rollback") public class Rollback { - @XmlValue - protected String value; + @XmlValue + protected String value; - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() { + return value; + } - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) { + this.value = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Sql.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Sql.java index 534536ddc..f2a951d7c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Sql.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Sql.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,68 +24,58 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "apply", - "rollback" + "apply", + "rollback" }) @XmlRootElement(name = "sql") public class Sql { - @XmlElement(required = true) - protected Apply apply; - @XmlElement(required = true) - protected Rollback rollback; + @XmlElement(required = true) + protected Apply apply; + @XmlElement(required = true) + protected Rollback rollback; - /** - * Gets the value of the apply property. - * - * @return - * possible object is - * {@link Apply } - * - */ - public Apply getApply() { - return apply; - } + /** + * Gets the value of the apply property. + * + * @return possible object is + * {@link Apply } + */ + public Apply getApply() { + return apply; + } - /** - * Sets the value of the apply property. - * - * @param value - * allowed object is - * {@link Apply } - * - */ - public void setApply(Apply value) { - this.apply = value; - } + /** + * Sets the value of the apply property. + * + * @param value allowed object is + * {@link Apply } + */ + public void setApply(Apply value) { + this.apply = value; + } - /** - * Gets the value of the rollback property. - * - * @return - * possible object is - * {@link Rollback } - * - */ - public Rollback getRollback() { - return rollback; - } + /** + * Gets the value of the rollback property. + * + * @return possible object is + * {@link Rollback } + */ + public Rollback getRollback() { + return rollback; + } - /** - * Sets the value of the rollback property. - * - * @param value - * allowed object is - * {@link Rollback } - * - */ - public void setRollback(Rollback value) { - this.rollback = value; - } + /** + * Sets the value of the rollback property. + * + * @param value allowed object is + * {@link Rollback } + */ + public void setRollback(Rollback value) { + this.rollback = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/UniqueConstraint.java b/src/main/java/com/avaje/ebean/dbmigration/migration/UniqueConstraint.java index f560218cc..0301e9a4a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/UniqueConstraint.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/UniqueConstraint.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "uniqueConstraint") public class UniqueConstraint { - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "columnNames", required = true) - protected String columnNames; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "columnNames", required = true) + protected String columnNames; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the columnNames property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumnNames() { - return columnNames; - } + /** + * Gets the value of the columnNames property. + * + * @return possible object is + * {@link String } + */ + public String getColumnNames() { + return columnNames; + } - /** - * Sets the value of the columnNames property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumnNames(String value) { - this.columnNames = value; - } + /** + * Sets the value of the columnNames property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumnNames(String value) { + this.columnNames = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java index 5fce3ba11..055ae7918 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java @@ -16,7 +16,8 @@ import java.io.InputStream; */ public class MigrationXmlReader { - private static final MigrationXmlReader INSTANCE = new MigrationXmlReader(); + private MigrationXmlReader() { + } /** * Read and return a Migration from an xml document at the given resource path. @@ -28,7 +29,7 @@ public class MigrationXmlReader { throw new IllegalArgumentException("No resource found for path [" + resourcePath + "]"); } - return INSTANCE.read(is); + return read(is); } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriter.java b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriter.java index 9c19f0382..5fb293a37 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriter.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriter.java @@ -45,10 +45,7 @@ public class MigrationXmlWriter { writer.close(); - } catch (IOException e) { - throw new RuntimeException(e); - - } catch (JAXBException e) { + } catch (IOException | JAXBException e) { throw new RuntimeException(e); } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/CurrentModel.java b/src/main/java/com/avaje/ebean/dbmigration/model/CurrentModel.java index 99dd89acf..1b3949a5e 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/CurrentModel.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/CurrentModel.java @@ -85,7 +85,7 @@ public class CurrentModel { } public void setChangeSet(ChangeSet changeSet) { - this.changeSet = changeSet; + this.changeSet = changeSet; } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundForeignKey.java b/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundForeignKey.java index 2d4803603..b528544cc 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundForeignKey.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundForeignKey.java @@ -16,8 +16,8 @@ public class MCompoundForeignKey { private String name; private final String referenceTable; - private final List columns = new ArrayList(); - private final List referenceColumns = new ArrayList(); + private final List columns = new ArrayList<>(); + private final List referenceColumns = new ArrayList<>(); private String indexName; public MCompoundForeignKey(String name, String referenceTable, String indexName) { diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundUniqueConstraint.java b/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundUniqueConstraint.java index 2bd087eb1..3d13e20ef 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundUniqueConstraint.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundUniqueConstraint.java @@ -3,8 +3,8 @@ package com.avaje.ebean.dbmigration.model; /** * A unique constraint for multiple columns. *

- * Note that unique constraint on a single column is instead - * a boolean flag on the associated MColumn. + * Note that unique constraint on a single column is instead + * a boolean flag on the associated MColumn. *

*/ public class MCompoundUniqueConstraint { diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MConfiguration.java b/src/main/java/com/avaje/ebean/dbmigration/model/MConfiguration.java index f6165a670..1c24a7650 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MConfiguration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MConfiguration.java @@ -27,8 +27,8 @@ public class MConfiguration { /** * Apply the migration configuration. *

- * It is expected that these are applied in the correct chronological order - * from earliest to latest. + * It is expected that these are applied in the correct chronological order + * from earliest to latest. *

*/ public void apply(Configuration configuration) { diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java b/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java index 5b3e4a112..dc4e83af8 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java @@ -4,6 +4,7 @@ import com.avaje.ebean.dbmigration.migration.CreateIndex; import com.avaje.ebean.dbmigration.migration.DropIndex; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -15,7 +16,7 @@ public class MIndex { private String indexName; - private List columns = new ArrayList(); + private List columns = new ArrayList<>(); /** * Create a single column non unique index. @@ -32,9 +33,7 @@ public class MIndex { public MIndex(String indexName, String tableName, String[] columnNames) { this.tableName = tableName; this.indexName = indexName; - for (int i = 0; i < columnNames.length; i++) { - this.columns.add(columnNames[i]); - } + Collections.addAll(this.columns, columnNames); } public MIndex(CreateIndex createIndex) { @@ -101,7 +100,6 @@ public class MIndex { * Return true if the index has changed. */ private boolean changed(MIndex newIndex) { - if (!tableName.equals(newIndex.getTableName())) { return true; } @@ -119,12 +117,9 @@ public class MIndex { private List split(String columns) { - - List colList = new ArrayList(); + List colList = new ArrayList<>(); String[] cols = columns.split(","); - for (int i = 0; i columns = new LinkedHashMap(); + private Map columns = new LinkedHashMap<>(); /** * Compound unique constraints. */ - private List uniqueConstraints = new ArrayList(); + private List uniqueConstraints = new ArrayList<>(); /** * Compound foreign keys. */ - private List compoundKeys = new ArrayList(); + private List compoundKeys = new ArrayList<>(); /** * Column name for the 'When created' column. This can be used for the initial effective start date when adding @@ -122,11 +122,11 @@ public class MTable { */ private AddColumn addColumn; - private List droppedColumns = new ArrayList(); + private List droppedColumns = new ArrayList<>(); /** * Create a copy of this table structure as a 'draft' table. - * + *

* Note that both tables contain @DraftOnly MColumns and these are filtered out * later when creating the CreateTable object. */ @@ -369,7 +369,7 @@ public class MTable { public List allHistoryColumns(boolean includeDropped) { - List columnNames = new ArrayList(columns.size()); + List columnNames = new ArrayList<>(columns.size()); for (MColumn column : columns.values()) { if (column.isIncludeInHistory()) { columnNames.add(column.getName()); @@ -444,7 +444,7 @@ public class MTable { * Return the list of columns that make the primary key. */ public List primaryKeyColumns() { - List pk = new ArrayList(3); + List pk = new ArrayList<>(3); for (MColumn column : allColumns()) { if (column.isPrimaryKey()) { pk.add(column); @@ -590,7 +590,7 @@ public class MTable { * Return true if the foreign key names are not unique. */ private boolean hasDuplicateForeignKeys() { - Set fkNames = new HashSet(); + Set fkNames = new HashSet<>(); for (MCompoundForeignKey fk : compoundKeys) { if (!fkNames.add(fk.getName())) { return true; diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java b/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java index b621bb6ce..ba4bccaa3 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java @@ -4,7 +4,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.FileFilter; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -42,23 +41,18 @@ public class MigrationModel { private void readMigrations() { // find all the migration xml files - File[] xmlFiles = modelDirectory.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.getName().toLowerCase().endsWith(modelSuffix); - } - }); + File[] xmlFiles = modelDirectory.listFiles(pathname -> pathname.getName().toLowerCase().endsWith(modelSuffix)); - List resources = new ArrayList(); + List resources = new ArrayList<>(); - for (File xmlFile: xmlFiles) { + for (File xmlFile : xmlFiles) { resources.add(new MigrationResource(xmlFile, createVersion(xmlFile))); } // sort into version order before applying Collections.sort(resources); - for (MigrationResource migrationResource: resources) { + for (MigrationResource migrationResource : resources) { logger.debug("read {}", migrationResource); model.apply(migrationResource.read(), migrationResource.getVersion()); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java b/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java index e3a41fdc2..1b0dbadf3 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java @@ -28,12 +28,12 @@ public class ModelContainer { /** * All the tables in the model. */ - private final Map tables = new LinkedHashMap(); + private final Map tables = new LinkedHashMap<>(); /** * All the non unique non foreign key indexes. */ - private final Map indexes = new LinkedHashMap(); + private final Map indexes = new LinkedHashMap<>(); private final PendingDrops pendingDrops = new PendingDrops(); @@ -307,7 +307,7 @@ public class ModelContainer { MTable table = getTable(dropColumn.getTableName()); if (table == null) { - throw new IllegalArgumentException("Table ["+dropColumn.getTableName()+"] not found?"); + throw new IllegalArgumentException("Table [" + dropColumn.getTableName() + "] not found?"); } table.registerPendingDropColumn(dropColumn.getColumnName()); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/ModelDiff.java b/src/main/java/com/avaje/ebean/dbmigration/model/ModelDiff.java index da50becb7..b0c7ae749 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/ModelDiff.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/ModelDiff.java @@ -30,12 +30,12 @@ public class ModelDiff { /** * List of 'create' type changes. */ - private final List applyChanges = new ArrayList(); + private final List applyChanges = new ArrayList<>(); /** * List of 'drop' type changes. Expected to be placed into a separate DDL script. */ - private final List dropChanges = new ArrayList(); + private final List dropChanges = new ArrayList<>(); /** * Construct with a base model. diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java b/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java index cb4235f92..456202cec 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java @@ -16,7 +16,7 @@ import java.util.List; */ public class PendingDrops { - private final LinkedHashMap map = new LinkedHashMap(); + private final LinkedHashMap map = new LinkedHashMap<>(); /** * Add a 'pending drops' changeSet for the given version. @@ -36,7 +36,7 @@ public class PendingDrops { */ public List pendingDrops() { - List versions = new ArrayList(); + List versions = new ArrayList<>(); for (Entry value : map.values()) { if (value.hasPendingDrops()) { versions.add(value.version.asString()); @@ -86,7 +86,7 @@ public class PendingDrops { } if (migration.getChangeSet().isEmpty()) { - throw new IllegalArgumentException("The remaining pendingDrops changeSets in migration ["+pendingVersion+"] are suppressDropsForever=true and can't be applied"); + throw new IllegalArgumentException("The remaining pendingDrops changeSets in migration [" + pendingVersion + "] are suppressDropsForever=true and can't be applied"); } if (!entry.containsSuppressForever()) { @@ -143,7 +143,7 @@ public class PendingDrops { final MigrationVersion version; - final List list = new ArrayList(); + final List list = new ArrayList<>(); Entry(MigrationVersion version) { this.version = version; @@ -206,10 +206,10 @@ public class PendingDrops { Iterator iterator = pending.iterator(); while (iterator.hasNext()) { Object pendingDrop = iterator.next(); - if (pendingDrop instanceof DropColumn && dropColumnIn((DropColumn)pendingDrop, appliedDrops)) { + if (pendingDrop instanceof DropColumn && dropColumnIn((DropColumn) pendingDrop, appliedDrops)) { iterator.remove(); - } else if (pendingDrop instanceof DropTable && dropTableIn((DropTable)pendingDrop, appliedDrops)) { + } else if (pendingDrop instanceof DropTable && dropTableIn((DropTable) pendingDrop, appliedDrops)) { iterator.remove(); } } @@ -220,7 +220,7 @@ public class PendingDrops { */ private boolean dropTableIn(DropTable pendingDrop, ChangeSet appliedDrops) { for (Object o : appliedDrops.getChangeSetChildren()) { - if (o instanceof DropTable && sameTable(pendingDrop, (DropTable)o)) { + if (o instanceof DropTable && sameTable(pendingDrop, (DropTable) o)) { return true; } } @@ -251,7 +251,7 @@ public class PendingDrops { */ private boolean sameColumn(DropColumn pending, DropColumn o) { return pending.getColumnName().equals(o.getColumnName()) - && pending.getTableName().equals(o.getTableName()); + && pending.getTableName().equals(o.getTableName()); } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/PlatformDdlWriter.java b/src/main/java/com/avaje/ebean/dbmigration/model/PlatformDdlWriter.java index 1a6f3f965..3c65d0920 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/PlatformDdlWriter.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/PlatformDdlWriter.java @@ -83,7 +83,7 @@ public class PlatformDdlWriter { protected FileWriter createWriter(File path, String fullVersion, String suffix) throws IOException { - File applyFile = new File(path, fullVersion + suffix); + File applyFile = new File(path, fullVersion + suffix); return new FileWriter(applyFile); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java index e18c53356..f891798ab 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java @@ -165,7 +165,7 @@ public class ModelBuildContext { int ixCount = 0; int uqCount = 0; Collection cols = draftTable.allColumns(); - for (MColumn col: cols) { + for (MColumn col : cols) { if (col.getForeignKeyName() != null) { // Note that we adjust the 'references' table later in a second pass // after we know all the tables that are 'draftable' @@ -176,10 +176,10 @@ public class ModelBuildContext { col.setForeignKeyIndex(foreignKeyIndexName(draftTable.getName(), indexCols, ++ixCount)); } // adjust the unique constraint names - if (col.getUnique() != null){ + if (col.getUnique() != null) { col.setUnique(uniqueConstraintName(draftTable.getName(), col.getName(), ++uqCount)); } - if (col.getUniqueOneToOne() != null){ + if (col.getUniqueOneToOne() != null) { col.setUniqueOneToOne(uniqueConstraintName(draftTable.getName(), col.getName(), ++uqCount)); } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java index f7c122954..4dde64375 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java @@ -15,22 +15,22 @@ import com.avaje.ebeaninternal.server.deploy.TableJoinColumn; */ public class ModelBuildIntersectionTable { - private final ModelBuildContext ctx; + private final ModelBuildContext ctx; - private final BeanPropertyAssocMany manyProp; - private final TableJoin intersectionTableJoin; - private final TableJoin tableJoin; + private final BeanPropertyAssocMany manyProp; + private final TableJoin intersectionTableJoin; + private final TableJoin tableJoin; private MTable intersectionTable; private int countForeignKey; - public ModelBuildIntersectionTable(ModelBuildContext ctx, BeanPropertyAssocMany manyProp) { - this.ctx = ctx; - this.manyProp = manyProp; - this.intersectionTableJoin = manyProp.getIntersectionTableJoin(); - this.tableJoin = manyProp.getTableJoin(); - } + public ModelBuildIntersectionTable(ModelBuildContext ctx, BeanPropertyAssocMany manyProp) { + this.ctx = ctx; + this.manyProp = manyProp; + this.intersectionTableJoin = manyProp.getIntersectionTableJoin(); + this.tableJoin = manyProp.getTableJoin(); + } public void build() { @@ -38,7 +38,7 @@ public class ModelBuildIntersectionTable { MTable existingTable = ctx.addTable(intersectionTable); if (existingTable != null) { throw new IllegalStateException("Property " + manyProp.getFullBeanName() + " has duplicate ManyToMany intersection table " + intersectionTable.getName() - + ". Please use @JoinTable to define unique table to use"); + + ". Please use @JoinTable to define unique table to use"); } buildFkConstraints(); @@ -47,21 +47,21 @@ public class ModelBuildIntersectionTable { ctx.createDraft(intersectionTable, false); } - } + } - private void buildFkConstraints() { + private void buildFkConstraints() { - BeanDescriptor localDesc = manyProp.getBeanDescriptor(); - buildFkConstraints(localDesc, intersectionTableJoin.columns(), true); + BeanDescriptor localDesc = manyProp.getBeanDescriptor(); + buildFkConstraints(localDesc, intersectionTableJoin.columns(), true); - BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); - buildFkConstraints(targetDesc, tableJoin.columns(), false); + BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); + buildFkConstraints(targetDesc, tableJoin.columns(), false); intersectionTable.checkDuplicateForeignKeys(); - } + } - - private void buildFkConstraints(BeanDescriptor desc, TableJoinColumn[] columns, boolean direction) { + + private void buildFkConstraints(BeanDescriptor desc, TableJoinColumn[] columns, boolean direction) { String tableName = intersectionTableJoin.getTable(); String baseTable = ctx.normaliseTable(desc.getBaseTable()); @@ -71,50 +71,50 @@ public class ModelBuildIntersectionTable { MCompoundForeignKey foreignKey = new MCompoundForeignKey(fkName, desc.getBaseTable(), fkIndex); intersectionTable.addForeignKey(foreignKey); - for (int i = 0; i < columns.length; i++) { - String localCol = direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); - String refCol = !direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String localCol = direction ? column.getForeignDbColumn() : column.getLocalDbColumn(); + String refCol = !direction ? column.getForeignDbColumn() : column.getLocalDbColumn(); foreignKey.addColumnPair(localCol, refCol); - } + } } - private MTable createTable() { + private MTable createTable() { - BeanDescriptor localDesc = manyProp.getBeanDescriptor(); - BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); + BeanDescriptor localDesc = manyProp.getBeanDescriptor(); + BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); String tableName = intersectionTableJoin.getTable(); MTable table = new MTable(tableName); - if (!manyProp.isExcludedFromHistory()) { - if (localDesc.isHistorySupport()) { - table.setWithHistory(true); - } - } + if (!manyProp.isExcludedFromHistory()) { + if (localDesc.isHistorySupport()) { + table.setWithHistory(true); + } + } table.setPkName(ctx.primaryKeyName(tableName)); - TableJoinColumn[] columns = intersectionTableJoin.columns(); - for (int i = 0; i < columns.length; i++) { - addColumn(table, localDesc, columns[i].getForeignDbColumn(), columns[i].getLocalDbColumn()); - } + TableJoinColumn[] columns = intersectionTableJoin.columns(); + for (TableJoinColumn column : columns) { + addColumn(table, localDesc, column.getForeignDbColumn(), column.getLocalDbColumn()); + } - TableJoinColumn[] otherColumns = tableJoin.columns(); - for (int i = 0; i < otherColumns.length; i++) { - addColumn(table, targetDesc, otherColumns[i].getLocalDbColumn(), otherColumns[i].getForeignDbColumn()); - } + TableJoinColumn[] otherColumns = tableJoin.columns(); + for (TableJoinColumn otherColumn : otherColumns) { + addColumn(table, targetDesc, otherColumn.getLocalDbColumn(), otherColumn.getForeignDbColumn()); + } return table; - } + } - private void addColumn(MTable table, BeanDescriptor desc, String column, String findPropColumn) { + private void addColumn(MTable table, BeanDescriptor desc, String column, String findPropColumn) { - BeanProperty p = desc.getIdBinder().findBeanProperty(findPropColumn); - if (p == null) { - throw new RuntimeException("Could not find id property for " + findPropColumn); - } + BeanProperty p = desc.getIdBinder().findBeanProperty(findPropColumn); + if (p == null) { + throw new RuntimeException("Could not find id property for " + findPropColumn); + } MColumn col = new MColumn(column, ctx.getColumnDefn(p, true), true); col.setPrimaryKey(true); table.addColumn(col); - } + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java index 2ad3925e2..7fb97ec5c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java @@ -54,8 +54,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { private void addIndexes(IndexDefinition[] indexes) { if (indexes != null) { - for (int i = 0; i < indexes.length; i++) { - IndexDefinition index = indexes[i]; + for (IndexDefinition index : indexes) { String[] columns = index.getColumns(); indexSet.add(columns); @@ -166,7 +165,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { ImportedId importedId = p.getImportedId(); - List modelColumns = new ArrayList(columns.length); + List modelColumns = new ArrayList<>(columns.length); MCompoundForeignKey compoundKey = null; if (columns.length > 1) { @@ -178,9 +177,9 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { table.addForeignKey(compoundKey); } - for (int i = 0; i < columns.length; i++) { + for (TableJoinColumn column : columns) { - String dbCol = columns[i].getLocalDbColumn(); + String dbCol = column.getLocalDbColumn(); BeanProperty importedProperty = importedId.findMatchImport(dbCol); if (importedProperty == null) { throw new RuntimeException("Imported BeanProperty not found?"); @@ -223,7 +222,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { } @Override - public void visitScalar(BeanProperty p) { + public void visitScalar(BeanProperty p) { if (p.isSecondaryTable()) { lastColumn = null; @@ -263,7 +262,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { lastColumn = col; table.addColumn(col); - } + } /** * Build the check constraint clause given the db column and values. @@ -369,4 +368,4 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { return val != null && !val.isEmpty(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/BeanVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/BeanVisitor.java index 3483c88d0..44f0fb8c8 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/BeanVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/BeanVisitor.java @@ -9,10 +9,10 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; */ public interface BeanVisitor { - /** - * Visit a BeanDescriptor and return a PropertyVisitor to use to visit each + /** + * Visit a BeanDescriptor and return a PropertyVisitor to use to visit each * property on the entity bean (return null to skip visiting this bean). - */ + */ ModelBuildPropertyVisitor visitBean(BeanDescriptor descriptor); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java index b25add8e5..2f35f0410 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java @@ -64,8 +64,7 @@ public class VisitAllUsing { } BeanProperty[] propertiesNonTransient = desc.propertiesNonTransient(); - for (int i = 0; i < propertiesNonTransient.length; i++) { - BeanProperty p = propertiesNonTransient[i]; + for (BeanProperty p : propertiesNonTransient) { if (p.isDDLColumn()) { visit(propertyVisitor, p); } @@ -91,8 +90,8 @@ public class VisitAllUsing { // Embedded bean pv.visitEmbedded(assocOne); BeanProperty[] embProps = assocOne.getProperties(); - for (int i = 0; i < embProps.length; i++) { - pv.visitEmbeddedScalar(embProps[i], assocOne); + for (BeanProperty embProp : embProps) { + pv.visitEmbeddedScalar(embProp, assocOne); } } else if (assocOne.isOneToOneExported()) { @@ -110,8 +109,8 @@ public class VisitAllUsing { pv.visitCompound(compound); BeanProperty[] properties = compound.getScalarProperties(); - for (int i = 0; i < properties.length; i++) { - pv.visitCompoundScalar(compound, properties[i]); + for (BeanProperty property : properties) { + pv.visitCompoundScalar(compound, property); } } else { @@ -151,8 +150,8 @@ public class VisitAllUsing { public void visit(InheritInfo inheritInfo) { BeanProperty[] propertiesLocal = inheritInfo.desc().propertiesLocal(); - for (int i = 0; i < propertiesLocal.length; i++) { - owner.visit(pv, propertiesLocal[i]); + for (BeanProperty aPropertiesLocal : propertiesLocal) { + owner.visit(pv, aPropertiesLocal); } } } diff --git a/src/main/java/com/avaje/ebean/event/BeanFindController.java b/src/main/java/com/avaje/ebean/event/BeanFindController.java index f53eeb602..6d51b8e4f 100644 --- a/src/main/java/com/avaje/ebean/event/BeanFindController.java +++ b/src/main/java/com/avaje/ebean/event/BeanFindController.java @@ -25,7 +25,7 @@ public interface BeanFindController { /** * Return true if this controller should intercept and process this find request. - * + *

* Return false to allow the default behavior to process the request. */ boolean isInterceptFind(BeanQueryRequest request); @@ -37,7 +37,7 @@ public interface BeanFindController { /** * Return true if this controller should intercept and process this findMany request. - * + *

* Return false to allow the default behavior to process the request. */ boolean isInterceptFindMany(BeanQueryRequest request); diff --git a/src/main/java/com/avaje/ebean/event/BeanPersistController.java b/src/main/java/com/avaje/ebean/event/BeanPersistController.java index 6896350d0..69f6f6b68 100644 --- a/src/main/java/com/avaje/ebean/event/BeanPersistController.java +++ b/src/main/java/com/avaje/ebean/event/BeanPersistController.java @@ -11,16 +11,14 @@ package com.avaje.ebean.event; * for the insert, update, delete or fetch. To explicitly use this same * transaction you should use this transaction via methods on EbeanServer. *

- * - *
- * 
- *        Object extaBeanToSave = ...;
- *        Transaction t = request.getTransaction();
- *        EbeanServer server = request.getEbeanServer();
- *        server.save(extraBeanToSave, t);
- * 
- * 
- * + *
{@code
+ *
+ *   Object extaBeanToSave = ...;
+ *   Transaction t = request.getTransaction();
+ *   EbeanServer server = request.getEbeanServer();
+ *   server.save(extraBeanToSave, t);
+ *
+ * }
*

* It is worth noting that BeanPersistListener is different in three main ways * from BeanPersistController postXXX methods. @@ -47,9 +45,8 @@ public interface BeanPersistController { *

* Lowest values are executed first. *

- * - * @return an int used to control the order BeanPersistController's are - * executed + * + * @return an int used to control the order BeanPersistController's are executed */ int getExecutionOrder(); diff --git a/src/main/java/com/avaje/ebean/event/BeanPersistListener.java b/src/main/java/com/avaje/ebean/event/BeanPersistListener.java index ad4c0eb66..94a630b63 100644 --- a/src/main/java/com/avaje/ebean/event/BeanPersistListener.java +++ b/src/main/java/com/avaje/ebean/event/BeanPersistListener.java @@ -17,13 +17,13 @@ import java.util.Set; * from BeanPersistController postXXX methods. *
    *
  • - * BeanPersistListener only sees successfully committed events. - * BeanPersistController pre and post methods occur before the commit or a - * rollback and will see events that are later rolled back + * BeanPersistListener only sees successfully committed events. + * BeanPersistController pre and post methods occur before the commit or a + * rollback and will see events that are later rolled back *
  • *
  • - * BeanPersistListener runs in a background thread and will not effect the - * response time of the actual persist where as BeanPersistController code will + * BeanPersistListener runs in a background thread and will not effect the + * response time of the actual persist where as BeanPersistController code will *
  • *
*

@@ -31,6 +31,7 @@ import java.util.Set; * A BeanPersistListener is either found automatically via class path search or * can be added programmatically via {@link ServerConfig#add(BeanPersistListener)}}. *

+ * * @see ServerConfig#add(BeanPersistListener) */ public interface BeanPersistListener { @@ -43,35 +44,30 @@ public interface BeanPersistListener { /** * Notified that a bean has been inserted. - * - * @param bean - * The bean that was inserted. + * + * @param bean The bean that was inserted. */ void inserted(Object bean); /** * Notified that a bean has been updated. - * - * @param bean - * The bean that was updated. - * @param updatedProperties - * The properties that were modified by this update. + * + * @param bean The bean that was updated. + * @param updatedProperties The properties that were modified by this update. */ void updated(Object bean, Set updatedProperties); /** * Notified that a bean has been deleted. - * - * @param bean - * The bean that was deleted. + * + * @param bean The bean that was deleted. */ void deleted(Object bean); /** * Notified that a bean has been soft deleted. * - * @param bean - * The bean that was soft deleted. + * @param bean The bean that was soft deleted. */ void softDeleted(Object bean); diff --git a/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java b/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java index 1893b480e..55b07de91 100644 --- a/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java +++ b/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java @@ -1,14 +1,13 @@ package com.avaje.ebean.event; import com.avaje.ebean.EbeanServer; -import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; /** * Fired after a bean is constructed, but not yet loaded from database. *

- * Note: You MUST NOT set any default values, as in a following step, + * Note: You MUST NOT set any default values, as in a following step, * properties will get unload. Use {@link BeanPostLoad} instead. - * + *

* it's intended to do some dependency-injection here. * If you plan to use this feature you should use {@link EbeanServer#createEntityBean(Class)} * to create new beans. @@ -26,12 +25,12 @@ public interface BeanPostConstructListener { * Called immediately after construction. Perform DI here. */ void autowire(Object bean); - + /** * Called after every @PostConstruct annotated method of the bean is executed */ void postConstruct(Object bean); - + /** * Called after {@link EbeanServer#createEntityBean(Class)}. Only for new beans. * intended to set default values here. diff --git a/src/main/java/com/avaje/ebean/event/BulkTableEvent.java b/src/main/java/com/avaje/ebean/event/BulkTableEvent.java index 419e04c9c..5f2bd0c73 100644 --- a/src/main/java/com/avaje/ebean/event/BulkTableEvent.java +++ b/src/main/java/com/avaje/ebean/event/BulkTableEvent.java @@ -2,8 +2,6 @@ package com.avaje.ebean.event; /** * The bulk table event. - * - * @author Robin Bygrave */ public interface BulkTableEvent { diff --git a/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java b/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java index e3583cf7b..9161488a0 100644 --- a/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java +++ b/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java @@ -1,19 +1,15 @@ package com.avaje.ebean.event; -import java.util.Set; - import com.avaje.ebean.Ebean; +import java.util.Set; + /** * Listen for bulk table events that occur. *

* These events can be triggered via * {@link Ebean#externalModification(String, boolean, boolean, boolean)} or * automatically determined from Ebean bulk update statements. - *

- * - * @author Robin Bygrave - * */ public interface BulkTableEventListener { diff --git a/src/main/java/com/avaje/ebean/event/ServerConfigStartup.java b/src/main/java/com/avaje/ebean/event/ServerConfigStartup.java index 7ac3f0b84..de5b858b1 100644 --- a/src/main/java/com/avaje/ebean/event/ServerConfigStartup.java +++ b/src/main/java/com/avaje/ebean/event/ServerConfigStartup.java @@ -7,9 +7,6 @@ import com.avaje.ebean.config.ServerConfig; *

* Provides a simple way to construct and register multiple listeners and * adapters that need shared services without using DI. - *

- * - * @author Robin Bygrave */ public interface ServerConfigStartup { diff --git a/src/main/java/com/avaje/ebean/event/changelog/BeanChange.java b/src/main/java/com/avaje/ebean/event/changelog/BeanChange.java index 4deb57d00..9bb359121 100644 --- a/src/main/java/com/avaje/ebean/event/changelog/BeanChange.java +++ b/src/main/java/com/avaje/ebean/event/changelog/BeanChange.java @@ -52,7 +52,7 @@ public class BeanChange { } public String toString() { - return "table:" + table + " id:" + id+" values:"+values; + return "table:" + table + " id:" + id + " values:" + values; } /** diff --git a/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java b/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java index 5e229acf8..4f86166fb 100644 --- a/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java +++ b/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java @@ -44,12 +44,12 @@ public class ChangeSet { /** * Arbitrary user context information expected to be optionally populated by ChangeLogPrepare. */ - Map userContext; + Map userContext; /** * The bean changes. */ - List changes = new ArrayList(); + List changes = new ArrayList<>(); /** * Construct with a txnId. @@ -180,9 +180,9 @@ public class ChangeSet { /** * Return a user context value - anything you set yourself in ChangeLogListener prepare(). */ - public Map getUserContext() { + public Map getUserContext() { if (userContext == null) { - userContext = new LinkedHashMap(); + userContext = new LinkedHashMap<>(); } return userContext; } @@ -194,7 +194,7 @@ public class ChangeSet { * in the foreground thread. *

*/ - public void setUserContext(Map userContext) { + public void setUserContext(Map userContext) { this.userContext = userContext; } diff --git a/src/main/java/com/avaje/ebean/event/package.html b/src/main/java/com/avaje/ebean/event/package.html index 83dea44fa..3a984105d 100644 --- a/src/main/java/com/avaje/ebean/event/package.html +++ b/src/main/java/com/avaje/ebean/event/package.html @@ -1,10 +1,10 @@ - - Persist and Query Event Controllers and Listeners + + Persist and Query Event Controllers and Listeners Persist and Query Event Controllers and Listeners - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/event/readaudit/ReadEvent.java b/src/main/java/com/avaje/ebean/event/readaudit/ReadEvent.java index 904742c95..5a95494af 100644 --- a/src/main/java/com/avaje/ebean/event/readaudit/ReadEvent.java +++ b/src/main/java/com/avaje/ebean/event/readaudit/ReadEvent.java @@ -159,7 +159,7 @@ public class ReadEvent { */ public Map getUserContext() { if (userContext == null) { - userContext = new LinkedHashMap(); + userContext = new LinkedHashMap<>(); } return userContext; } diff --git a/src/main/java/com/avaje/ebean/meta/MetaBeanInfo.java b/src/main/java/com/avaje/ebean/meta/MetaBeanInfo.java index 3059dc368..d5fa97fe5 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaBeanInfo.java +++ b/src/main/java/com/avaje/ebean/meta/MetaBeanInfo.java @@ -8,10 +8,10 @@ public interface MetaBeanInfo { * Collect the current query plan statistics return the non-empty statistics. */ List collectQueryPlanStatistics(boolean reset); - + /** * Collect the current query plan statistics return all the statistics (include query plans that haven't had query executions). - */ + */ List collectAllQueryPlanStatistics(boolean reset); } diff --git a/src/main/java/com/avaje/ebean/meta/MetaInfoManager.java b/src/main/java/com/avaje/ebean/meta/MetaInfoManager.java index 795b1a999..cddda6663 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaInfoManager.java +++ b/src/main/java/com/avaje/ebean/meta/MetaInfoManager.java @@ -33,9 +33,8 @@ public interface MetaInfoManager { * This is used to look at the amount of lazy loading occurring for a given * query origin point and highlight potential for tuning a query. *

- * - * @param reset - * Set to true to reset the underlying statistics after collection. + * + * @param reset Set to true to reset the underlying statistics after collection. */ List collectNodeStatistics(boolean reset); diff --git a/src/main/java/com/avaje/ebean/meta/MetaObjectGraphNodeStats.java b/src/main/java/com/avaje/ebean/meta/MetaObjectGraphNodeStats.java index 4ed1934d3..9a70d302f 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaObjectGraphNodeStats.java +++ b/src/main/java/com/avaje/ebean/meta/MetaObjectGraphNodeStats.java @@ -8,7 +8,7 @@ import com.avaje.ebean.bean.ObjectGraphNode; * These statistics can be used to identify origin queries that result in lots * of lazy loading. *

- * + * * @see MetaInfoManager#collectNodeStatistics(boolean) */ public interface MetaObjectGraphNodeStats { @@ -38,4 +38,4 @@ public interface MetaObjectGraphNodeStats { */ long getTotalBeans(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/meta/MetaQueryPlanOriginCount.java b/src/main/java/com/avaje/ebean/meta/MetaQueryPlanOriginCount.java index 84caeb727..0c8040e84 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaQueryPlanOriginCount.java +++ b/src/main/java/com/avaje/ebean/meta/MetaQueryPlanOriginCount.java @@ -9,7 +9,7 @@ import com.avaje.ebean.bean.ObjectGraphNode; * This basically points to the bit of original code and query that results in * this query directly or via lazy loading. *

- * + * * @see MetaQueryPlanStatistic * @see MetaInfoManager#collectQueryPlanStatistics(boolean) */ @@ -30,4 +30,4 @@ public interface MetaQueryPlanOriginCount { */ long getCount(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/meta/MetaQueryPlanStatistic.java b/src/main/java/com/avaje/ebean/meta/MetaQueryPlanStatistic.java index 371ba6a28..54a771fd0 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaQueryPlanStatistic.java +++ b/src/main/java/com/avaje/ebean/meta/MetaQueryPlanStatistic.java @@ -4,7 +4,7 @@ import java.util.List; /** * Query execution statistics Meta data. - * + * * @see MetaInfoManager#collectQueryPlanStatistics(boolean) */ public interface MetaQueryPlanStatistic { diff --git a/src/main/java/com/avaje/ebean/overview.html b/src/main/java/com/avaje/ebean/overview.html index 4ce74e843..7f85d3c41 100644 --- a/src/main/java/com/avaje/ebean/overview.html +++ b/src/main/java/com/avaje/ebean/overview.html @@ -1,6 +1,6 @@ - Ebean API + Ebean API Ebean Object Relational Mapping (start at @@ -9,48 +9,48 @@ Ebean Object Relational Mapping (start at

Ebean

-Provides the main API for fetching and persisting beans with Ebean. + Provides the main API for fetching and persisting beans with Ebean.

-For a full description of the query language refer to Query. + For a full description of the query language refer to Query.

-  +  

-

-EXAMPLE 1: Simple fetch -

-
{@code
+  

+ EXAMPLE 1: Simple fetch +

+
{@code
 // fetch order 10
 Order order = Ebean.find(Order.class, 10);
 }
-

-EXAMPLE 2: Fetch an Object with associations -

-
{@code
+  

+ EXAMPLE 2: Fetch an Object with associations +

+
{@code
 // fetch Customer 7 including their billing and shipping addresses
 Customer customer = Ebean.find(Customer.class)
     .fetch("billingAddress");
     .fetch("shippingAddress");
     .setId(7)
     .findUnique();
-	
-		
+
+
 Address billAddr = customer.getBillingAddress();
 Address shipAddr = customer.getShippingAddress();
 }
-

-EXAMPLE 3: Fetch a list of Objects with associations -

-
{@code
+  

+ EXAMPLE 3: Fetch a list of Objects with associations +

+
{@code
 // Note: This example shows a "Partial Object".
-//       For the product objects associated with the 
+//       For the product objects associated with the
 //       order details only the product id and name is
 //       fetched (the product objects are partially populated).
-		
+
 // fetch orders for customer.id = 2
 List orderList = Ebean.find(Order.class);
     .fetch("customer")
@@ -62,14 +62,14 @@ List orderList = Ebean.find(Order.class);
 
 
 // Note: Only the product id and name is fetched for the
-//       product details. This is referred to as a 
-//       "Partial Object" (one that is partially populated).  
+//       product details. This is referred to as a
+//       "Partial Object" (one that is partially populated).
 
 
 // code that traverses the object graph...
 
 Order order = orderList.get(0);
-Customer customer = order.getCustomer();	
+Customer customer = order.getCustomer();
 Address shipAddr = customer.getShippingAddress();
 
 List details = order.getDetails();
@@ -79,10 +79,10 @@ String productName = product.getName();
 
 }
-

-EXAMPLE 4: Create and save an Order -

-
{@code
+  

+ EXAMPLE 4: Create and save an Order +

+
{@code
 // get a Customer reference so we don't hit the database
 Customer custRef = Ebean.getReference(Customer.class, 7);
 
@@ -109,25 +109,25 @@ Ebean.save(newOrder);
 
 }
-

-EXAMPLE 5: Use another database -

-
{@code
+  

+ EXAMPLE 5: Use another database +

+
{@code
 // Get access to the Human Resources EbeanServer/Database
 EbeanServer hrServer = Ebean.getServer("HR");
-                                    
-                              
+
+
 // fetch contact 3 from the HR database
 Contact contact = hrServer.find(Contact.class, 3);
-                                    
+
 contact.setStatus(Contact.Status.INACTIVE);
 ...
-                                    
+
 // save the contact back to the HR database
-hrServer.save(contact); 	
+hrServer.save(contact);
 }
- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/package.html b/src/main/java/com/avaje/ebean/package.html index 3f1155af5..0c825cc56 100644 --- a/src/main/java/com/avaje/ebean/package.html +++ b/src/main/java/com/avaje/ebean/package.html @@ -1,13 +1,13 @@ - Ebean core API + Ebean core API Core API (see EbeanServer and Ebean).

Ebean

-Provides the main API for fetching and persisting beans with eBean. + Provides the main API for fetching and persisting beans with eBean.

{@code
@@ -83,4 +83,4 @@ hrServer.save(contact);
 }
- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/plugin/ExtraTypeFactory.java b/src/main/java/com/avaje/ebean/plugin/ExtraTypeFactory.java index be43b26a9..9ea259668 100644 --- a/src/main/java/com/avaje/ebean/plugin/ExtraTypeFactory.java +++ b/src/main/java/com/avaje/ebean/plugin/ExtraTypeFactory.java @@ -13,5 +13,5 @@ public interface ExtraTypeFactory { /** * Provide extra types to Ebean. */ - List createTypes(ServerConfig config, Object objectMapper); + List> createTypes(ServerConfig config, Object objectMapper); } diff --git a/src/main/java/com/avaje/ebean/search/TextCommonTerms.java b/src/main/java/com/avaje/ebean/search/TextCommonTerms.java index c1cad820a..36d50fd29 100644 --- a/src/main/java/com/avaje/ebean/search/TextCommonTerms.java +++ b/src/main/java/com/avaje/ebean/search/TextCommonTerms.java @@ -5,7 +5,6 @@ package com.avaje.ebean.search; *

* This maps to an ElasticSearch "common terms query". *

- *
{@code
  *
  *  TextCommonTerms options = new TextCommonTerms()
@@ -20,7 +19,6 @@ package com.avaje.ebean.search;
  *    .findList();
  *
  * }
- * *
{@code
  *
  *   // ElasticSearch expression
diff --git a/src/main/java/com/avaje/ebean/search/TextQueryString.java b/src/main/java/com/avaje/ebean/search/TextQueryString.java
index a50af6ff1..b5e3c5324 100644
--- a/src/main/java/com/avaje/ebean/search/TextQueryString.java
+++ b/src/main/java/com/avaje/ebean/search/TextQueryString.java
@@ -5,7 +5,6 @@ package com.avaje.ebean.search;
  * 

* This maps to an ElasticSearch "query string query". *

- * *
{@code
  *
  *  TextQueryString options = new TextQueryString()
@@ -20,8 +19,6 @@ package com.avaje.ebean.search;
  *       .findList();
  *
  * }
- * - * *
{@code
  *
  *  // just use default options
@@ -33,12 +30,10 @@ package com.avaje.ebean.search;
  *       .findList();
  *
  * }
- * */ public class TextQueryString { public static final int DEFAULT_FUZZY_MAX_EXPANSIONS = 50; - public static final int DEFAULT_MAX_DETERMINIZED_STATES = 10000; protected final String[] fields; @@ -62,8 +57,6 @@ public class TextQueryString { protected boolean lowercaseExpandedTerms = true; - protected boolean enablePositionIncrements = true; - protected int fuzzyMaxExpansions = DEFAULT_FUZZY_MAX_EXPANSIONS; protected String fuzziness; @@ -78,8 +71,6 @@ public class TextQueryString { protected boolean autoGeneratePhraseQueries; - protected int maxDeterminizedStates = DEFAULT_MAX_DETERMINIZED_STATES; - protected String minShouldMatch; protected boolean lenient; @@ -192,14 +183,6 @@ public class TextQueryString { return this; } - /** - * Set enable position increments mode. - */ - public TextQueryString enablePositionIncrements(boolean enablePositionIncrements) { - this.enablePositionIncrements = enablePositionIncrements; - return this; - } - /** * Set fuzzy max expansions. */ @@ -247,6 +230,7 @@ public class TextQueryString { this.analyzeWildcard = analyzeWildcard; return this; } + /** * Set the auto generate phrase queries mode. */ @@ -255,14 +239,6 @@ public class TextQueryString { return this; } - /** - * Set the max determinized states. - */ - public TextQueryString maxDeterminizedStates(int maxDeterminizedStates) { - this.maxDeterminizedStates = maxDeterminizedStates; - return this; - } - /** * Set the time zone. */ @@ -363,13 +339,6 @@ public class TextQueryString { return lowercaseExpandedTerms; } - /** - * Return the enable position increments mode. - */ - public boolean isEnablePositionIncrements() { - return enablePositionIncrements; - } - /** * Return the fuzzy max expansions. */ @@ -419,13 +388,6 @@ public class TextQueryString { return autoGeneratePhraseQueries; } - /** - * Return the max determinized states. - */ - public int getMaxDeterminizedStates() { - return maxDeterminizedStates; - } - /** * Return the time zone. */ diff --git a/src/main/java/com/avaje/ebean/search/TextSimple.java b/src/main/java/com/avaje/ebean/search/TextSimple.java index 789f764ba..995f800f1 100644 --- a/src/main/java/com/avaje/ebean/search/TextSimple.java +++ b/src/main/java/com/avaje/ebean/search/TextSimple.java @@ -5,7 +5,6 @@ package com.avaje.ebean.search; *

* This maps to an ElasticSearch "simple text query". *

- * *
{@code
  *
  *  TextSimple options = new TextSimple()
diff --git a/src/main/java/com/avaje/ebean/stylesheet.css b/src/main/java/com/avaje/ebean/stylesheet.css
index 634ca5705..21caf36d8 100644
--- a/src/main/java/com/avaje/ebean/stylesheet.css
+++ b/src/main/java/com/avaje/ebean/stylesheet.css
@@ -3,40 +3,89 @@
 /* Define colors, fonts and other style attributes here to override the defaults */
 
 /* Page background color */
-body { 
-background-color: #FFFFFF; 
-font-family: Arial, Helvetica, sans-serif; 
-font-size:10pt;
+body {
+  background-color: #FFFFFF;
+  font-family: Arial, Helvetica, sans-serif;
+  font-size: 10pt;
 }
 
 pre.code {
-	padding:1em; 
-	margin-left:2em; 
-	border: 1px solid #ccc; 
-	background-color: #eee; 
+  padding: 1em;
+  margin-left: 2em;
+  border: 1px solid #ccc;
+  background-color: #eee;
 }
 
 /* Headings */
-h1 { font-size: 14pt }
+h1 {
+  font-size: 14pt
+}
 
-#overviewexamples h3 {font-size:10pt }
+#overviewexamples h3 {
+  font-size: 10pt
+}
 
 /* Table colors */
-.TableHeadingColor     { background: #CCCCFF } /* Dark mauve */
-.TableSubHeadingColor  { background: #EEEEFF } /* Light mauve */
-.TableRowColor         { background: #FFFFFF } /* White */
+.TableHeadingColor {
+  background: #CCCCFF
+}
+
+/* Dark mauve */
+.TableSubHeadingColor {
+  background: #EEEEFF
+}
+
+/* Light mauve */
+.TableRowColor {
+  background: #FFFFFF
+}
+
+/* White */
 
 /* Font used in left-hand frame lists */
-.FrameTitleFont   { font-size: 12pt; font-family: Helvetica, Arial, sans-serif }
-.FrameHeadingFont { font-size:  10pt; font-family: Helvetica, Arial, sans-serif }
-.FrameItemFont    { font-size:  10pt; font-family: Helvetica, Arial, sans-serif }
+.FrameTitleFont {
+  font-size: 12pt;
+  font-family: Helvetica, Arial, sans-serif
+}
+
+.FrameHeadingFont {
+  font-size: 10pt;
+  font-family: Helvetica, Arial, sans-serif
+}
+
+.FrameItemFont {
+  font-size: 10pt;
+  font-family: Helvetica, Arial, sans-serif
+}
 
 /* Navigation bar fonts and colors */
-.NavBarCell1    { background-color:#EEEEFF;} /* Light mauve */
-.NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */
-.NavBarFont1    { font-family: Arial, Helvetica, sans-serif; color:#000000;}
-.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
+.NavBarCell1 {
+  background-color: #EEEEFF;
+}
 
-.NavBarCell2    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
-.NavBarCell3    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
+/* Light mauve */
+.NavBarCell1Rev {
+  background-color: #00008B;
+}
+
+/* Dark Blue */
+.NavBarFont1 {
+  font-family: Arial, Helvetica, sans-serif;
+  color: #000000;
+}
+
+.NavBarFont1Rev {
+  font-family: Arial, Helvetica, sans-serif;
+  color: #FFFFFF;
+}
+
+.NavBarCell2 {
+  font-family: Arial, Helvetica, sans-serif;
+  background-color: #FFFFFF;
+}
+
+.NavBarCell3 {
+  font-family: Arial, Helvetica, sans-serif;
+  background-color: #FFFFFF;
+}
 
diff --git a/src/main/java/com/avaje/ebean/text/PathProperties.java b/src/main/java/com/avaje/ebean/text/PathProperties.java
index 6eeb0b4dd..9944f2a8b 100644
--- a/src/main/java/com/avaje/ebean/text/PathProperties.java
+++ b/src/main/java/com/avaje/ebean/text/PathProperties.java
@@ -42,7 +42,7 @@ public class PathProperties implements FetchPath {
    */
   public PathProperties() {
     this.rootProps = new Props(this, null, null);
-    this.pathMap = new LinkedHashMap();
+    this.pathMap = new LinkedHashMap<>();
     this.pathMap.put(null, rootProps);
   }
 
@@ -172,7 +172,7 @@ public class PathProperties implements FetchPath {
     }
 
     private Props(PathProperties owner, String parentPath, String path) {
-      this(owner, parentPath, path, new LinkedHashSet());
+      this(owner, parentPath, path, new LinkedHashSet<>());
     }
 
     public String getPath() {
diff --git a/src/main/java/com/avaje/ebean/text/StringFormatter.java b/src/main/java/com/avaje/ebean/text/StringFormatter.java
index 1fd677cb4..82585a3e7 100644
--- a/src/main/java/com/avaje/ebean/text/StringFormatter.java
+++ b/src/main/java/com/avaje/ebean/text/StringFormatter.java
@@ -5,8 +5,6 @@ package com.avaje.ebean.text;
  * 

* Basic interface to support CSV, JSON and XML processing. *

- * - * @author rbygrave */ public interface StringFormatter { diff --git a/src/main/java/com/avaje/ebean/text/StringParser.java b/src/main/java/com/avaje/ebean/text/StringParser.java index c03371310..41784dc21 100644 --- a/src/main/java/com/avaje/ebean/text/StringParser.java +++ b/src/main/java/com/avaje/ebean/text/StringParser.java @@ -4,9 +4,6 @@ package com.avaje.ebean.text; * Convert a String value into an Object value. *

* Basic interface to support CSV, JSON and XML processing. - *

- * - * @author rbygrave */ public interface StringParser { diff --git a/src/main/java/com/avaje/ebean/text/TextException.java b/src/main/java/com/avaje/ebean/text/TextException.java index ac41a3c07..9b0953407 100644 --- a/src/main/java/com/avaje/ebean/text/TextException.java +++ b/src/main/java/com/avaje/ebean/text/TextException.java @@ -2,8 +2,6 @@ package com.avaje.ebean.text; /** * An exception occurred typically in processing CSV, JSON or XML. - * - * @author rbygrave */ public class TextException extends RuntimeException { diff --git a/src/main/java/com/avaje/ebean/text/TimeStringParser.java b/src/main/java/com/avaje/ebean/text/TimeStringParser.java index 8185acfed..087136bce 100644 --- a/src/main/java/com/avaje/ebean/text/TimeStringParser.java +++ b/src/main/java/com/avaje/ebean/text/TimeStringParser.java @@ -4,8 +4,6 @@ import java.sql.Time; /** * Parser for TIME types that supports both HH:mm:ss and HH:mm. - * - * @author rbygrave */ public final class TimeStringParser implements StringParser { @@ -49,8 +47,7 @@ public final class TimeStringParser implements StringParser { return new Time(hour, minute, second); } catch (NumberFormatException e) { - throw new java.lang.IllegalArgumentException("Number format Error parsing time [" + s + "] " - + e.getMessage(), e); + throw new java.lang.IllegalArgumentException("Number format Error parsing time [" + s + "] " + e.getMessage(), e); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/text/csv/CsvCallback.java b/src/main/java/com/avaje/ebean/text/csv/CsvCallback.java index b550be252..d91d942bc 100644 --- a/src/main/java/com/avaje/ebean/text/csv/CsvCallback.java +++ b/src/main/java/com/avaje/ebean/text/csv/CsvCallback.java @@ -9,9 +9,7 @@ import com.avaje.ebean.EbeanServer; * processing. It is expected that the DefaultCsvCallback provides a good base * class that you can extend. *

- * - * @author rbygrave - * + * * @param */ public interface CsvCallback { @@ -28,12 +26,11 @@ public interface CsvCallback { /** * Read the header row. *

- * This is only called if {@link CsvReader#setHasHeader(boolean,boolean)} has + * This is only called if {@link CsvReader#setHasHeader(boolean, boolean)} has * been set to true. *

- * - * @param line - * the header line content. + * + * @param line the header line content. */ void readHeader(String[] line); @@ -54,13 +51,10 @@ public interface CsvCallback { * and will not save the bean for you. You have complete control and must do * these things yourself (if that is want you want). *

- * - * @param row - * the index of the content being processed - * @param line - * the content that has been used to load the bean - * @param bean - * the entity bean after it has been loaded from the csv content + * + * @param row the index of the content being processed + * @param line the content that has been used to load the bean + * @param bean the entity bean after it has been loaded from the csv content */ void processBean(int row, String[] line, T bean); @@ -78,11 +72,9 @@ public interface CsvCallback { * This gives the callback the opportunity to rollback the transaction if one * was created. *

- * - * @param row - * the row that the error has occured on - * @param e - * the error that occured + * + * @param row the row that the error has occured on + * @param e the error that occured */ void endWithError(int row, Exception e); diff --git a/src/main/java/com/avaje/ebean/text/csv/CsvReader.java b/src/main/java/com/avaje/ebean/text/csv/CsvReader.java index 76ce0f2ef..7b707277c 100644 --- a/src/main/java/com/avaje/ebean/text/csv/CsvReader.java +++ b/src/main/java/com/avaje/ebean/text/csv/CsvReader.java @@ -1,47 +1,45 @@ package com.avaje.ebean.text.csv; +import com.avaje.ebean.text.StringParser; + import java.io.Reader; import java.util.Locale; -import com.avaje.ebean.text.StringParser; - /** * Reads CSV data turning it into object graphs that you can be saved (inserted) * or processed yourself. - * *

* This first example doesn't use a {@link CsvCallback} and this means it will * automatically create a transaction, save the customers and commit the * transaction when successful. *

- * - *
+ *
+ * 
{@code
  * try {
- *   File f = new File("src/test/resources/test1.csv");
- * 
+ *   File f = new File("src/test/resources/test1.csv");
+ *
  *   FileReader reader = new FileReader(f);
- * 
+ *
  *   CsvReader<Customer> csvReader = Ebean.createCsvReader(Customer.class);
- * 
+ *
  *   csvReader.setPersistBatchSize(20);
- * 
- *   csvReader.addProperty("status");
+ *
+ *   csvReader.addProperty("status");
  *   // ignore the next property
  *   csvReader.addIgnore();
- *   csvReader.addProperty("name");
- *   csvReader.addDateTime("anniversary", "dd-MMM-yyyy");
- *   csvReader.addProperty("billingAddress.line1");
- *   csvReader.addProperty("billingAddress.city");
- * 
+ *   csvReader.addProperty("name");
+ *   csvReader.addDateTime("anniversary", "dd-MMM-yyyy");
+ *   csvReader.addProperty("billingAddress.line1");
+ *   csvReader.addProperty("billingAddress.city");
+ *
  *   csvReader.process(reader);
- * 
+ *
  * } catch (Exception e) {
  *   throw new RuntimeException(e);
  * }
- * 
- * - * @param - * the entity bean type + * }
+ * + * @param the entity bean type */ public interface CsvReader { @@ -170,4 +168,4 @@ public interface CsvReader { */ void process(Reader reader, CsvCallback callback) throws Exception; -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/text/csv/DefaultCsvCallback.java b/src/main/java/com/avaje/ebean/text/csv/DefaultCsvCallback.java index 822924888..20b7d7ba2 100644 --- a/src/main/java/com/avaje/ebean/text/csv/DefaultCsvCallback.java +++ b/src/main/java/com/avaje/ebean/text/csv/DefaultCsvCallback.java @@ -15,9 +15,7 @@ import org.slf4j.LoggerFactory; * For customising the processing you can extend this object and override the * appropriate methods. *

- * - * @author rob - * + * * @param */ public class DefaultCsvCallback implements CsvCallback { @@ -89,12 +87,10 @@ public class DefaultCsvCallback implements CsvCallback { /** * Override to read the heading line. *

- * This is only called if {@link CsvReader#setHasHeader(boolean,boolean)} is + * This is only called if {@link CsvReader#setHasHeader(boolean, boolean)} is * set to true. - *

*

* By default this does nothing (effectively ignoring the heading). - *

*/ public void readHeader(String[] line) { diff --git a/src/main/java/com/avaje/ebean/text/json/EJson.java b/src/main/java/com/avaje/ebean/text/json/EJson.java index e22eb0903..f915f8244 100644 --- a/src/main/java/com/avaje/ebean/text/json/EJson.java +++ b/src/main/java/com/avaje/ebean/text/json/EJson.java @@ -1,5 +1,10 @@ package com.avaje.ebean.text.json; +import com.avaje.ebeaninternal.server.type.ModifyAwareList; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + import java.io.IOException; import java.io.Reader; import java.io.Writer; @@ -8,11 +13,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import com.avaje.ebeaninternal.server.type.ModifyAwareList; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; - /** * Utility that converts between JSON content and simple java Maps/Lists. */ @@ -24,14 +24,14 @@ public class EJson { public static String write(Object object) throws IOException { return EJsonWriter.write(object); } - + /** * Write the nested Map/List as json to the writer. */ public static void write(Object object, Writer writer) throws IOException { EJsonWriter.write(object, writer); } - + /** * Write the nested Map/List as json to the jsonGenerator. */ @@ -50,35 +50,35 @@ public class EJson { * Parse the json and return as a Map additionally specifying if the returned map should * be modify aware meaning that it can detect when it has been modified. */ - public static Map parseObject(String json, boolean modifyAware) throws IOException { + public static Map parseObject(String json, boolean modifyAware) throws IOException { return EJsonReader.parseObject(json, modifyAware); } /** * Parse the json and return as a Map. */ - public static Map parseObject(String json) throws IOException { + public static Map parseObject(String json) throws IOException { return EJsonReader.parseObject(json); } /** * Parse the json and return as a Map taking a reader. */ - public static Map parseObject(Reader reader, boolean modifyAware) throws IOException { + public static Map parseObject(Reader reader, boolean modifyAware) throws IOException { return EJsonReader.parseObject(reader, modifyAware); } /** * Parse the json and return as a Map taking a reader. */ - public static Map parseObject(Reader reader) throws IOException { + public static Map parseObject(Reader reader) throws IOException { return EJsonReader.parseObject(reader); } - + /** * Parse the json and return as a Map taking a JsonParser. */ - public static Map parseObject(JsonParser parser) throws IOException { + public static Map parseObject(JsonParser parser) throws IOException { return EJsonReader.parseObject(parser); } @@ -88,7 +88,7 @@ public class EJson { * Used when the first token is checked to see if the value is null prior to calling this. *

*/ - public static Map parseObject(JsonParser parser, JsonToken token) throws IOException { + public static Map parseObject(JsonParser parser, JsonToken token) throws IOException { return EJsonReader.parseObject(parser, token); } @@ -105,14 +105,14 @@ public class EJson { public static List parseList(String json) throws IOException { return EJsonReader.parseList(json); } - + /** * Parse the json and return as a List taking a Reader. */ public static List parseList(Reader reader) throws IOException { return EJsonReader.parseList(reader); } - + /** * Parse the json and return as a List taking a JsonParser. */ @@ -124,7 +124,7 @@ public class EJson { * Parse the json returning as a List taking into account the current token. */ public static List parseList(JsonParser parser, JsonToken currentToken) throws IOException { - return (List)EJsonReader.parse(parser, currentToken, false); + return (List) EJsonReader.parse(parser, currentToken, false); } /** @@ -133,14 +133,14 @@ public class EJson { public static Object parse(String json) throws IOException { return EJsonReader.parse(json); } - + /** * Parse the json and return as a List or Map. */ public static Object parse(Reader reader) throws IOException { return EJsonReader.parse(reader); } - + /** * Parse the json and return as a List or Map. */ @@ -156,6 +156,6 @@ public class EJson { if (list == null) { return null; } - return ((ModifyAwareList)list).asSet(); + return ((ModifyAwareList) list).asSet(); } } diff --git a/src/main/java/com/avaje/ebean/text/json/EJsonReader.java b/src/main/java/com/avaje/ebean/text/json/EJsonReader.java index dba25227c..c52230926 100644 --- a/src/main/java/com/avaje/ebean/text/json/EJsonReader.java +++ b/src/main/java/com/avaje/ebean/text/json/EJsonReader.java @@ -1,5 +1,13 @@ package com.avaje.ebean.text.json; +import com.avaje.ebeaninternal.server.type.ModifyAwareFlag; +import com.avaje.ebeaninternal.server.type.ModifyAwareList; +import com.avaje.ebeaninternal.server.type.ModifyAwareMap; +import com.avaje.ebeaninternal.server.type.ModifyAwareOwner; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + import java.io.IOException; import java.io.Reader; import java.io.StringReader; @@ -9,28 +17,20 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import com.avaje.ebeaninternal.server.type.ModifyAwareFlag; -import com.avaje.ebeaninternal.server.type.ModifyAwareList; -import com.avaje.ebeaninternal.server.type.ModifyAwareMap; -import com.avaje.ebeaninternal.server.type.ModifyAwareOwner; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; - class EJsonReader { static final JsonFactory json = new JsonFactory(); @SuppressWarnings("unchecked") - static Map parseObject(String json, boolean modifyAware) throws IOException { + static Map parseObject(String json, boolean modifyAware) throws IOException { return (Map) parse(json, modifyAware); } @SuppressWarnings("unchecked") - static Map parseObject(String json) throws IOException { + static Map parseObject(String json) throws IOException { return (Map) parse(json); } - + @SuppressWarnings("unchecked") static Map parseObject(Reader reader) throws IOException { return (Map) parse(reader); @@ -48,7 +48,7 @@ class EJsonReader { @SuppressWarnings("unchecked") static Map parseObject(JsonParser parser, JsonToken token) throws IOException { - return (Map)parse(parser, token, false); + return (Map) parse(parser, token, false); } @SuppressWarnings("unchecked") @@ -60,12 +60,12 @@ class EJsonReader { static List parseList(String json) throws IOException { return (List) parse(json); } - + @SuppressWarnings("unchecked") static List parseList(Reader reader) throws IOException { return (List) parse(reader); } - + @SuppressWarnings("unchecked") static List parseList(JsonParser parser, boolean modifyAware) throws IOException { return (List) parse(parser, modifyAware); @@ -112,12 +112,12 @@ class EJsonReader { private final ModifyAwareFlag modifyAwareOwner; private int depth; - + private Stack stack; private Context currentContext; - EJsonReader(JsonParser parser, boolean modifyAware) { + EJsonReader(JsonParser parser, boolean modifyAware) { this.parser = parser; this.modifyAware = modifyAware; this.modifyAwareOwner = (modifyAware) ? new ModifyAwareFlag() : null; @@ -167,12 +167,18 @@ class EJsonReader { token = parser.nextToken(); // if it is a simple value just return it switch (token) { - case VALUE_NULL: return null; - case VALUE_FALSE: return Boolean.FALSE; - case VALUE_TRUE: return Boolean.TRUE; - case VALUE_STRING: return parser.getText(); - case VALUE_NUMBER_INT: return parser.getLongValue(); - case VALUE_NUMBER_FLOAT: return parser.getDecimalValue(); + case VALUE_NULL: + return null; + case VALUE_FALSE: + return Boolean.FALSE; + case VALUE_TRUE: + return Boolean.TRUE; + case VALUE_STRING: + return parser.getText(); + case VALUE_NUMBER_INT: + return parser.getLongValue(); + case VALUE_NUMBER_FLOAT: + return parser.getDecimalValue(); } } @@ -195,59 +201,59 @@ class EJsonReader { private void processJsonToken(JsonToken token) throws IOException { switch (token) { - case START_ARRAY: - startArray(); - break; + case START_ARRAY: + startArray(); + break; - case START_OBJECT: - startObject(); - break; + case START_OBJECT: + startObject(); + break; - case FIELD_NAME: - currentContext.setKey(parser.getCurrentName()); - break; + case FIELD_NAME: + currentContext.setKey(parser.getCurrentName()); + break; - case VALUE_STRING: - setValue(parser.getValueAsString()); - break; + case VALUE_STRING: + setValue(parser.getValueAsString()); + break; - case VALUE_NUMBER_INT: - setValue(parser.getLongValue()); - break; - - case VALUE_NUMBER_FLOAT: - setValue(parser.getDecimalValue()); - break; + case VALUE_NUMBER_INT: + setValue(parser.getLongValue()); + break; - case VALUE_TRUE: - setValue(Boolean.TRUE); - break; + case VALUE_NUMBER_FLOAT: + setValue(parser.getDecimalValue()); + break; - case VALUE_FALSE: - setValue(Boolean.FALSE); - break; + case VALUE_TRUE: + setValue(Boolean.TRUE); + break; - case VALUE_NULL: - setValueNull(); - break; + case VALUE_FALSE: + setValue(Boolean.FALSE); + break; - case END_OBJECT: - endObject(); - break; + case VALUE_NULL: + setValueNull(); + break; - case END_ARRAY: - endArray(); - break; + case END_OBJECT: + endObject(); + break; - default: - break; + case END_ARRAY: + endArray(); + break; + + default: + break; } } - + private static final class Stack { - + private Context head; - + private void push(Context context) { if (context != null) { context.next = head; @@ -272,25 +278,30 @@ class EJsonReader { private static abstract class Context { Context next; + abstract void popContext(Context temp); + abstract Object getValue(); + abstract void setKey(String key); + abstract void setValue(Object value); + abstract void setValueNull(); } - + private static class ObjectContext extends Context { - + private final Map map; private String key; ObjectContext() { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); } ObjectContext(ModifyAwareOwner owner) { - map = new ModifyAwareMap(owner, new LinkedHashMap()); + map = new ModifyAwareMap<>(owner, new LinkedHashMap<>()); } public void popContext(Context temp) { @@ -315,15 +326,15 @@ class EJsonReader { } private static class ArrayContext extends Context { - + private final List values; ArrayContext() { - values = new ArrayList(); + values = new ArrayList<>(); } ArrayContext(ModifyAwareOwner owner) { - values = new ModifyAwareList(owner, new ArrayList()); + values = new ModifyAwareList<>(owner, new ArrayList<>()); } public void popContext(Context temp) { @@ -333,7 +344,7 @@ class EJsonReader { Object getValue() { return values; } - + void setValue(Object value) { values.add(value); } @@ -341,7 +352,8 @@ class EJsonReader { void setValueNull() { // ignore } - void setKey(String key) { + + void setKey(String key) { // not expected } } diff --git a/src/main/java/com/avaje/ebean/text/json/EJsonWriter.java b/src/main/java/com/avaje/ebean/text/json/EJsonWriter.java index 0deda8742..add09e160 100644 --- a/src/main/java/com/avaje/ebean/text/json/EJsonWriter.java +++ b/src/main/java/com/avaje/ebean/text/json/EJsonWriter.java @@ -1,5 +1,8 @@ package com.avaje.ebean.text.json; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonGenerator; + import java.io.IOException; import java.io.StringWriter; import java.io.Writer; @@ -11,9 +14,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; - class EJsonWriter { /** diff --git a/src/main/java/com/avaje/ebean/text/json/JsonContext.java b/src/main/java/com/avaje/ebean/text/json/JsonContext.java index dc67d9824..71d86e2b0 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonContext.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonContext.java @@ -61,20 +61,18 @@ public interface JsonContext { /** * Create and return a new bean reading for the bean type given the JSON options and source. *

- * Note that JsonOption provides an option for setting a persistence context and also enabling - * further lazy loading. Further lazy loading requires a persistence context so if that is set - * on then a persistence context is created if there is not one set. - *

+ * Note that JsonOption provides an option for setting a persistence context and also enabling + * further lazy loading. Further lazy loading requires a persistence context so if that is set + * on then a persistence context is created if there is not one set. */ JsonBeanReader createBeanReader(Class cls, JsonParser parser, JsonReadOptions options) throws JsonIOException; /** * Create and return a new bean reading for the bean type given the JSON options and source. *

- * Note that JsonOption provides an option for setting a persistence context and also enabling - * further lazy loading. Further lazy loading requires a persistence context so if that is set - * on then a persistence context is created if there is not one set. - *

+ * Note that JsonOption provides an option for setting a persistence context and also enabling + * further lazy loading. Further lazy loading requires a persistence context so if that is set + * on then a persistence context is created if there is not one set. */ JsonBeanReader createBeanReader(BeanType beanType, JsonParser parser, JsonReadOptions options) throws JsonIOException; @@ -234,4 +232,4 @@ public interface JsonContext { */ void writeScalar(JsonGenerator generator, Object scalarValue) throws IOException; -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/text/json/JsonIOException.java b/src/main/java/com/avaje/ebean/text/json/JsonIOException.java index d14fc7c06..58f0a46eb 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonIOException.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonIOException.java @@ -8,6 +8,8 @@ package com.avaje.ebean.text.json; */ public class JsonIOException extends RuntimeException { + private static final long serialVersionUID = 3062982368161342209L; + /** * Construct with an underlying cause. */ diff --git a/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java b/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java index a8569d078..6864302c6 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java @@ -29,7 +29,7 @@ public class JsonReadOptions { * Default constructor. */ public JsonReadOptions() { - this.visitorMap = new LinkedHashMap>(); + this.visitorMap = new LinkedHashMap<>(); } /** @@ -64,9 +64,8 @@ public class JsonReadOptions { /** * Set to true to enable lazy loading on partially populated beans. *

- * If this is set to true a persistence context will be created if one has - * not already been supplied. - *

+ * If this is set to true a persistence context will be created if one has + * not already been supplied. */ public JsonReadOptions setEnableLazyLoading(boolean enableLazyLoading) { this.enableLazyLoading = enableLazyLoading; @@ -117,4 +116,4 @@ public class JsonReadOptions { this.loadContext = loadContext; } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/text/json/JsonWriteBeanVisitor.java b/src/main/java/com/avaje/ebean/text/json/JsonWriteBeanVisitor.java index 1ab885c81..c84b62829 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonWriteBeanVisitor.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonWriteBeanVisitor.java @@ -8,9 +8,7 @@ package com.avaje.ebean.text.json; * You register a JsonWriteBeanVisitor with {@link JsonWriteOptions}. *

* - * @param - * the type of entity bean - * + * @param the type of entity bean * @see JsonWriteOptions */ public interface JsonWriteBeanVisitor { @@ -19,11 +17,9 @@ public interface JsonWriteBeanVisitor { * Visit the bean that has just been writing it's content to JSON. You can * write your own additional JSON content to the JsonWriter if you wish. * - * @param bean - * the bean that has been writing it's content - * @param jsonWriter - * the JsonWriter which you can append custom json content to if you - * wish. + * @param bean the bean that has been writing it's content + * @param jsonWriter the JsonWriter which you can append custom json content to if you + * wish. */ void visit(T bean, JsonWriter jsonWriter); diff --git a/src/main/java/com/avaje/ebean/text/json/JsonWriteOptions.java b/src/main/java/com/avaje/ebean/text/json/JsonWriteOptions.java index c610d926e..5c80e0c43 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonWriteOptions.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonWriteOptions.java @@ -85,7 +85,7 @@ public class JsonWriteOptions { */ public JsonWriteOptions setPathVisitor(String path, JsonWriteBeanVisitor visitor) { if (visitorMap == null) { - visitorMap = new HashMap>(); + visitorMap = new HashMap<>(); } visitorMap.put(path, visitor); return this; diff --git a/src/main/java/com/avaje/ebean/text/json/package-info.java b/src/main/java/com/avaje/ebean/text/json/package-info.java index cdb33b989..0c1ea677d 100644 --- a/src/main/java/com/avaje/ebean/text/json/package-info.java +++ b/src/main/java/com/avaje/ebean/text/json/package-info.java @@ -1,29 +1,28 @@ /** * JSON formatting and parsing objects (See JsonContext). *

- * The goal is to provide JSON support taking into account + * The goal is to provide JSON support taking into account * various ORM issues such as partial objects (for fetching and * updating), reference beans and - * bi-directional relationships. + * bi-directional relationships. *

- * *

Example:

- *
+ * 
{@code
  *  // find some customers ...
- *  
- * List<Customer> list = Ebean.find(Customer.class)
- *     .select("id, name, status, shippingAddress")
- *     .fetch("billingAddress","line1, city")
- *     .fetch("billingAddress.country", "*")
- *     .fetch("contacts", "firstName,email")
- *     .order().desc("id")
+ *
+ * List list = Ebean.find(Customer.class)
+ *     .select("id, name, status, shippingAddress")
+ *     .fetch("billingAddress","line1, city")
+ *     .fetch("billingAddress.country", "*")
+ *     .fetch("contacts", "firstName,email")
+ *     .order().desc("id")
  *     .findList();
- * 
+ *
  * JsonContext json = Ebean.json();
  *
  *  // output as a JSON string
  * String jsonOutput = json.toJson(list);
- * 
- * 
+ * + * }
*/ -package com.avaje.ebean.text.json; \ No newline at end of file +package com.avaje.ebean.text.json; diff --git a/src/main/java/com/avaje/ebean/util/CamelCaseHelper.java b/src/main/java/com/avaje/ebean/util/CamelCaseHelper.java index 77241d949..4a73ffbb0 100644 --- a/src/main/java/com/avaje/ebean/util/CamelCaseHelper.java +++ b/src/main/java/com/avaje/ebean/util/CamelCaseHelper.java @@ -4,10 +4,8 @@ public class CamelCaseHelper { /** * To camel from underscore. - * - * @param underscore - * the underscore - * + * + * @param underscore the underscore * @return the string */ public static String toCamelFromUnderscore(String underscore) { diff --git a/src/main/java/com/avaje/ebean/util/ClassUtil.java b/src/main/java/com/avaje/ebean/util/ClassUtil.java index 50645921c..300145bb6 100644 --- a/src/main/java/com/avaje/ebean/util/ClassUtil.java +++ b/src/main/java/com/avaje/ebean/util/ClassUtil.java @@ -16,7 +16,7 @@ public class ClassUtil { Type[] typeArguments = getSuperclassTypeParameter(subclass); if (typeArguments.length != 2) { throw new IllegalArgumentException("Expected type with 2 generic argument types but got " - + typeArguments.length + " - " + Arrays.toString(typeArguments)); + + typeArguments.length + " - " + Arrays.toString(typeArguments)); } return getRawType(typeArguments[1]); diff --git a/src/main/java/com/avaje/ebean/util/StringHelper.java b/src/main/java/com/avaje/ebean/util/StringHelper.java index 24fcabbfc..384defbc4 100644 --- a/src/main/java/com/avaje/ebean/util/StringHelper.java +++ b/src/main/java/com/avaje/ebean/util/StringHelper.java @@ -37,7 +37,7 @@ public class StringHelper { throw new RuntimeException("missing quoted value at the end of " + tag); } - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); // recursively parse out the name value pairs... return parseNameQuotedValue(map, tag, 0); } @@ -47,7 +47,7 @@ public class StringHelper { * either single or double quotes). */ private static HashMap parseNameQuotedValue(HashMap map, - String tag, int pos) throws RuntimeException { + String tag, int pos) throws RuntimeException { int equalsPos = tag.indexOf("=", pos); if (equalsPos > -1) { @@ -55,14 +55,13 @@ public class StringHelper { char firstQuote = tag.charAt(equalsPos + 1); if (firstQuote != SINGLE_QUOTE && firstQuote != DOUBLE_QUOTE) { throw new RuntimeException("missing begin quote at " + (equalsPos) + "[" - + tag.charAt(equalsPos + 1) + "] in [" + tag + "]"); + + tag.charAt(equalsPos + 1) + "] in [" + tag + "]"); } // check for end quote... int endQuotePos = tag.indexOf(firstQuote, equalsPos + 2); if (endQuotePos == -1) { - throw new RuntimeException("missing end quote [" + firstQuote + "] after " + pos - + " in [" + tag + "]"); + throw new RuntimeException("missing end quote [" + firstQuote + "] after " + pos + " in [" + tag + "]"); } // we have a valid name and value... @@ -111,18 +110,15 @@ public class StringHelper { * Parses out a list of Name Value pairs that are delimited together. Will * always return a StringMap. If allNameValuePairs is null, or no name values * can be parsed out an empty StringMap is returned. - * - * @param allNameValuePairs - * the entire string to be parsed. - * @param listDelimiter - * (typically ';') the delimited between the list - * @param nameValueSeparator - * (typically '=') the separator between the name and value + * + * @param allNameValuePairs the entire string to be parsed. + * @param listDelimiter (typically ';') the delimited between the list + * @param nameValueSeparator (typically '=') the separator between the name and value */ public static Map delimitedToMap(String allNameValuePairs, - String listDelimiter, String nameValueSeparator) { + String listDelimiter, String nameValueSeparator) { - HashMap params = new HashMap(); + HashMap params = new HashMap<>(); if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) { return params; } @@ -133,11 +129,9 @@ public class StringHelper { /** * Trims off recurring strings from the front of a string. - * - * @param source - * the source string - * @param trim - * the string to trim off the front + * + * @param source the source string + * @param trim the string to trim off the front */ public static String trimFront(String source, String trim) { if (source == null) { @@ -162,7 +156,7 @@ public class StringHelper { * Recursively pulls out the key value pairs from a raw string. */ private static HashMap getKeyValue(HashMap map, int pos, - String allNameValuePairs, String listDelimiter, String nameValueSeparator) { + String allNameValuePairs, String listDelimiter, String nameValueSeparator) { if (pos >= allNameValuePairs.length()) { // dp("end as "+pos+" >= "+allNameValuePairs.length() ); @@ -183,7 +177,7 @@ public class StringHelper { // dp("Ignoring as nothing between delim and equals... // delim:"+delimPos+" eq:"+equalsPos); return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, - nameValueSeparator); + nameValueSeparator); } if (equalsPos > delimPos) { // there is a key without a value? @@ -193,7 +187,7 @@ public class StringHelper { map.put(key, null); } return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, - nameValueSeparator); + nameValueSeparator); } String key = allNameValuePairs.substring(pos, equalsPos); @@ -219,25 +213,20 @@ public class StringHelper { * Convert a string that has delimited values (say comma delimited) in a * String[]. You must explicitly choose whether or not to include empty values * (say two commas that a right beside each other. - * - *

+ *

* e.g. "alpha,beta,,theta"
* With keepEmpties true, this results in a String[] of size 4 with the third * one having a String of 0 length. With keepEmpties false, this results in a * String[] of size 3. - *

- *

- *

- *

+ *

* e.g. ",alpha,beta,,theta,"
* With keepEmpties true, this results in a String[] of size 6 with the * 1st,4th and 6th one having a String of 0 length. With keepEmpties false, * this results in a String[] of size 3. - *

*/ public static String[] delimitedToArray(String str, String delimiter, boolean keepEmpties) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); int startPos = 0; delimiter(str, delimiter, keepEmpties, startPos, list); String[] result = new String[list.size()]; @@ -245,7 +234,7 @@ public class StringHelper { } private static void delimiter(String str, String delimiter, boolean keepEmpties, int startPos, - ArrayList list) { + ArrayList list) { int endPos = str.indexOf(delimiter, startPos); if (endPos == -1) { @@ -272,24 +261,18 @@ public class StringHelper { * This returns the FIRST string in str that is bounded on the left by * leftBound, and bounded on the right by rightBound. This will return null if * the leftBound is not found within str. - * - *

+ *

* If leftBound can't be found this returns null. - *

- *

+ *

* This rightBound can't be found then this throws a * StringIndexOutOfBoundsException. - *

- * - * @param str - * the base string that we will search for the bounded string. - * @param leftBound - * the left bound of the string. - * @param rightBound - * the right bound of the string. + * + * @param str the base string that we will search for the bounded string. + * @param leftBound the left bound of the string. + * @param rightBound the right bound of the string. */ public static String getBoundedString(String str, String leftBound, String rightBound) - throws RuntimeException { + throws RuntimeException { if (str == null) { throw new RuntimeException("string to parse is null?"); @@ -317,7 +300,7 @@ public class StringHelper { * replaceString. Actually removes the left and right bound strings aswell. */ public static String setBoundedString(String str, String leftBound, String rightBound, - String replaceString) { + String replaceString) { int startPos = str.indexOf(leftBound); if (startPos > -1) { @@ -334,43 +317,13 @@ public class StringHelper { } } - // public static String replaceString(String str, String oldSub, String - // newSub) { - // - // if (str == null) { - // return null; - // } - // StringBuilder newSB = new StringBuilder(str.length()+20); - // int iPos = 0; - // int iPrevPos = 0; - // - // while (true) { - // iPos = str.indexOf(oldSub, iPrevPos); - // if (iPos > -1) { - // // found - // newSB.append(str.substring(iPrevPos, iPos)); - // newSB.append(newSub); - // iPrevPos = iPos + oldSub.length(); - // } else { - // // not found - // newSB.append(str.substring(iPrevPos)); - // break; - // } - // } - // - // return newSB.toString(); - // } - /** * This method takes a String and will replace all occurrences of the match * String with that of the replace String. - * - * @param source - * the source string - * @param match - * the string used to find a match - * @param replace - * the string used to replace match with + * + * @param source the source string + * @param match the string used to find a match + * @param replace the string used to replace match with * @return the source string after the search and replace */ public static String replaceString(String source, String match, String replace) { @@ -395,7 +348,7 @@ public class StringHelper { * occurs. */ public static String replaceString(String source, String match, String replace, - int additionalSize, int startPos, int endPos) { + int additionalSize, int startPos, int endPos) { if (source == null) { return null; @@ -461,14 +414,12 @@ public class StringHelper { * A search and replace with multiple matching strings. *

* Useful when converting CRNL CR and NL all to a BR tag for example. - *

- * - *
-   * 
-   * String[] multi = { "\r\n", "\r", "\n" };
-   * content = StringHelper.replaceStringMulti(content, multi, "<br/>");
-   * 
-   * 
+ *
{@code
+   *
+   * String[] multi = { "\r\n", "\r", "\n" };
+   * content = StringHelper.replaceStringMulti(content, multi, "
"); + * + * }
*/ public static String replaceStringMulti(String source, String[] match, String replace) { return replaceStringMulti(source, match, replace, 30, 0, source.length()); @@ -483,7 +434,7 @@ public class StringHelper { *

*/ public static String replaceStringMulti(String source, String[] match, String replace, - int additionalSize, int startPos, int endPos) { + int additionalSize, int startPos, int endPos) { int shortestMatch = match[0].length(); @@ -580,8 +531,8 @@ public class StringHelper { } private static boolean charMatch(int iChr, char[] chr) { - for (int i = 0; i < chr.length; i++) { - if (iChr == chr[i]) { + for (char aChr : chr) { + if (iChr == aChr) { return true; } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java b/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java index c1de039bd..95d82e27e 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java @@ -7,40 +7,40 @@ import java.util.List; */ public class BeanIdList { - private final List idList; + private final List idList; private boolean hasMore; - public BeanIdList(List idList) { - this.idList = idList; - } + public BeanIdList(List idList) { + this.idList = idList; + } - /** - * Add an Id to the list. - */ - public void add(Object id){ - idList.add(id); - } + /** + * Add an Id to the list. + */ + public void add(Object id) { + idList.add(id); + } - /** - * Return the list of Id's. - */ - public List getIdList() { - return idList; - } + /** + * Return the list of Id's. + */ + public List getIdList() { + return idList; + } - /** - * Return true if max rows was hit and there is more rows to fetch. - */ - public boolean isHasMore() { - return hasMore; - } + /** + * Return true if max rows was hit and there is more rows to fetch. + */ + public boolean isHasMore() { + return hasMore; + } - /** - * Set to true when max rows is hit and there are more rows to fetch. - */ - public void setHasMore(boolean hasMore) { - this.hasMore = hasMore; - } + /** + * Set to true when max rows is hit and there are more rows to fetch. + */ + public void setHasMore(boolean hasMore) { + this.hasMore = hasMore; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java index c0dc62556..c2d0a82eb 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java @@ -1,5 +1,7 @@ package com.avaje.ebeaninternal.api; +import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -8,8 +10,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; - /** * Parameters used for binding to a statement. *

@@ -18,18 +18,18 @@ import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; */ public class BindParams implements Serializable { - private static final long serialVersionUID = 4541081933302086285L; + private static final long serialVersionUID = 4541081933302086285L; - private final List positionedParameters = new ArrayList(); + private final List positionedParameters = new ArrayList<>(); - private final Map namedParameters = new LinkedHashMap(); - - /** - * This is the sql. For named parameters this is the sql after the named - * parameters have been replaced with question mark place holders and the - * parameters have been ordered by addNamedParamInOrder(). - */ - private String preparedSql; + private final Map namedParameters = new LinkedHashMap<>(); + + /** + * This is the sql. For named parameters this is the sql after the named + * parameters have been replaced with question mark place holders and the + * parameters have been ordered by addNamedParamInOrder(). + */ + private String preparedSql; /** * Bind hash and count used to detect when the bind values have changed such @@ -37,16 +37,16 @@ public class BindParams implements Serializable { */ private int[] bindHash; - public BindParams() { - } - + public BindParams() { + } + public int queryBindHash() { - int hc = namedParameters.hashCode(); - for (int i = 0; i < positionedParameters.size(); i++) { - hc = hc * 31 + positionedParameters.get(i).hashCode(); - } - return hc; - } + int hc = namedParameters.hashCode(); + for (Param positionedParameter : positionedParameters) { + hc = hc * 31 + positionedParameter.hashCode(); + } + return hc; + } /** * Return the hash that should be included with the query plan. @@ -84,136 +84,136 @@ public class BindParams implements Serializable { return new int[]{hc, bc}; } - /** - * Return a deep copy of the BindParams. - */ - public BindParams copy() { - BindParams copy = new BindParams(); - for (Param p : positionedParameters) { - copy.positionedParameters.add(p.copy()); - } - for (Entry entry : namedParameters.entrySet()) { + /** + * Return a deep copy of the BindParams. + */ + public BindParams copy() { + BindParams copy = new BindParams(); + for (Param p : positionedParameters) { + copy.positionedParameters.add(p.copy()); + } + for (Entry entry : namedParameters.entrySet()) { copy.namedParameters.put(entry.getKey(), entry.getValue().copy()); - } - return copy; - } - - /** - * Return true if there are no bind parameters. - */ - public boolean isEmpty() { - return positionedParameters.isEmpty() && namedParameters.isEmpty(); - } - - /** - * Return a Natural Key bind param if supported. - */ - public NaturalKeyBindParam getNaturalKeyBindParam() { - if (positionedParameters != null){ - return null; - } - if (namedParameters != null && namedParameters.size() == 1){ - Entry e = namedParameters.entrySet().iterator().next(); - return new NaturalKeyBindParam(e.getKey(), e.getValue().getInValue()); - } - return null; - } + } + return copy; + } - public int size() { - return positionedParameters.size(); - } + /** + * Return true if there are no bind parameters. + */ + public boolean isEmpty() { + return positionedParameters.isEmpty() && namedParameters.isEmpty(); + } - /** - * Return true if named parameters are being used and they have not yet been - * ordered. The sql needs to be prepared (named replaced with ?) and the - * parameters ordered. - */ - public boolean requiresNamedParamsPrepare() { - return !namedParameters.isEmpty(); - } + /** + * Return a Natural Key bind param if supported. + */ + public NaturalKeyBindParam getNaturalKeyBindParam() { + if (positionedParameters != null) { + return null; + } + if (namedParameters != null && namedParameters.size() == 1) { + Entry e = namedParameters.entrySet().iterator().next(); + return new NaturalKeyBindParam(e.getKey(), e.getValue().getInValue()); + } + return null; + } - /** - * Set a null parameter using position. - */ - public void setNullParameter(int position, int jdbcType) { - Param p = getParam(position); - p.setInNullType(jdbcType); - } + public int size() { + return positionedParameters.size(); + } - /** - * Set an In Out parameter using position. - */ - public void setParameter(int position, Object value, int outType) { + /** + * Return true if named parameters are being used and they have not yet been + * ordered. The sql needs to be prepared (named replaced with ?) and the + * parameters ordered. + */ + public boolean requiresNamedParamsPrepare() { + return !namedParameters.isEmpty(); + } - Param p = getParam(position); - p.setInValue(value); - p.setOutType(outType); - } + /** + * Set a null parameter using position. + */ + public void setNullParameter(int position, int jdbcType) { + Param p = getParam(position); + p.setInNullType(jdbcType); + } - /** - * Using position set the In value of a parameter. Note that for nulls you - * must use setNullParameter. - */ - public void setParameter(int position, Object value) { + /** + * Set an In Out parameter using position. + */ + public void setParameter(int position, Object value, int outType) { - Param p = getParam(position); - p.setInValue(value); - } + Param p = getParam(position); + p.setInValue(value); + p.setOutType(outType); + } - /** - * Register the parameter as an Out parameter using position. - */ - public void registerOut(int position, int outType) { - Param p = getParam(position); - p.setOutType(outType); - } + /** + * Using position set the In value of a parameter. Note that for nulls you + * must use setNullParameter. + */ + public void setParameter(int position, Object value) { - private Param getParam(String name) { - Param p = namedParameters.get(name); - if (p == null) { - p = new Param(); - namedParameters.put(name, p); - } - return p; - } + Param p = getParam(position); + p.setInValue(value); + } - private Param getParam(int position) { - int more = position - positionedParameters.size(); - if (more > 0) { - for (int i = 0; i < more; i++) { - positionedParameters.add(new Param()); - } - } - return positionedParameters.get(position - 1); - } + /** + * Register the parameter as an Out parameter using position. + */ + public void registerOut(int position, int outType) { + Param p = getParam(position); + p.setOutType(outType); + } - /** - * Set a named In Out parameter. - */ - public void setParameter(String name, Object value, int outType) { + private Param getParam(String name) { + Param p = namedParameters.get(name); + if (p == null) { + p = new Param(); + namedParameters.put(name, p); + } + return p; + } + + private Param getParam(int position) { + int more = position - positionedParameters.size(); + if (more > 0) { + for (int i = 0; i < more; i++) { + positionedParameters.add(new Param()); + } + } + return positionedParameters.get(position - 1); + } + + /** + * Set a named In Out parameter. + */ + public void setParameter(String name, Object value, int outType) { Param p = getParam(name); - p.setInValue(value); - p.setOutType(outType); - } + p.setInValue(value); + p.setOutType(outType); + } - /** - * Set a named In parameter that is null. - */ - public void setNullParameter(String name, int jdbcType) { - Param p = getParam(name); - p.setInNullType(jdbcType); - } + /** + * Set a named In parameter that is null. + */ + public void setNullParameter(String name, int jdbcType) { + Param p = getParam(name); + p.setInNullType(jdbcType); + } - /** - * Set a named In parameter that is not null. - */ - public Param setParameter(String name, Object value) { - - Param p = getParam(name); - p.setInValue(value); - return p; - } + /** + * Set a named In parameter that is not null. + */ + public Param setParameter(String name, Object value) { + + Param p = getParam(name); + p.setInValue(value); + return p; + } /** * Set an encryption key as a bind value. @@ -227,50 +227,50 @@ public class BindParams implements Serializable { return p; } - /** - * Register the named parameter as an Out parameter. - */ - public void registerOut(String name, int outType) { - Param p = getParam(name); - p.setOutType(outType); - } + /** + * Register the named parameter as an Out parameter. + */ + public void registerOut(String name, int outType) { + Param p = getParam(name); + p.setOutType(outType); + } - /** - * Return the Parameter for a given position. - */ - public Param getParameter(int position) { - // Used to read Out value by CallableSql - return getParam(position); - } + /** + * Return the Parameter for a given position. + */ + public Param getParameter(int position) { + // Used to read Out value by CallableSql + return getParam(position); + } - /** - * Return the named parameter. - */ - public Param getParameter(String name) { - return getParam(name); - } + /** + * Return the named parameter. + */ + public Param getParameter(String name) { + return getParam(name); + } - /** - * Return the values of ordered parameters. - */ - public List positionedParameters() { - return positionedParameters; - } + /** + * Return the values of ordered parameters. + */ + public List positionedParameters() { + return positionedParameters; + } - /** - * Set the sql with named parameters replaced with place holder ?. - */ - public void setPreparedSql(String preparedSql) { - this.preparedSql = preparedSql; - } + /** + * Set the sql with named parameters replaced with place holder ?. + */ + public void setPreparedSql(String preparedSql) { + this.preparedSql = preparedSql; + } - /** - * Return the sql with ? place holders (named parameters have been processed - * and ordered). - */ - public String getPreparedSql() { - return preparedSql; - } + /** + * Return the sql with ? place holders (named parameters have been processed + * and ordered). + */ + public String getPreparedSql() { + return preparedSql; + } /** * Return true if the bind hash and count has not changed. @@ -295,160 +295,160 @@ public class BindParams implements Serializable { } /** - * The bind parameters in the correct binding order. - *

- * This is the result of converting sql with named parameters - * into sql with ? and ordered parameters. - *

- */ - public static final class OrderedList { - - private final List paramList; - - private final StringBuilder preparedSql; + * The bind parameters in the correct binding order. + *

+ * This is the result of converting sql with named parameters + * into sql with ? and ordered parameters. + *

+ */ + public static final class OrderedList { - public OrderedList() { - this(new ArrayList()); - } - - public OrderedList(List paramList) { - this.paramList = paramList; - this.preparedSql = new StringBuilder(); - } - - /** - * Add a parameter in the correct binding order. - */ - public void add(Param param) { - paramList.add(param); - } - - /** - * Return the number of bind parameters in this list. - */ - public int size() { - return paramList.size(); - } - - /** - * Returns the ordered list of bind parameters. - */ - public List list() { - return paramList; - } - - /** - * Append parsedSql that has named parameters converted into ?. - */ - public void appendSql(String parsedSql) { - preparedSql.append(parsedSql); - } - - public String getPreparedSql() { - return preparedSql.toString(); - } - } - - /** - * A In Out capable parameter for the CallableStatement. - */ - public static final class Param implements Serializable { + private final List paramList; + + private final StringBuilder preparedSql; + + public OrderedList() { + this(new ArrayList<>()); + } + + public OrderedList(List paramList) { + this.paramList = paramList; + this.preparedSql = new StringBuilder(); + } + + /** + * Add a parameter in the correct binding order. + */ + public void add(Param param) { + paramList.add(param); + } + + /** + * Return the number of bind parameters in this list. + */ + public int size() { + return paramList.size(); + } + + /** + * Returns the ordered list of bind parameters. + */ + public List list() { + return paramList; + } + + /** + * Append parsedSql that has named parameters converted into ?. + */ + public void appendSql(String parsedSql) { + preparedSql.append(parsedSql); + } + + public String getPreparedSql() { + return preparedSql.toString(); + } + } + + /** + * A In Out capable parameter for the CallableStatement. + */ + public static final class Param implements Serializable { private static final long serialVersionUID = 1L; - + private boolean encryptionKey; - - private boolean isInParam; - private boolean isOutParam; + private boolean isInParam; - private int type; + private boolean isOutParam; - private Object inValue; + private int type; - private Object outValue; + private Object inValue; - /** - * Construct a Parameter. - */ - public Param() { - } + private Object outValue; - public int queryBindCount() { - if (inValue == null) { - return 0; - } - if (inValue instanceof Collection){ - return ((Collection)inValue).size(); - } - return 1; - } - - /** - * Create a deep copy of the Param. - */ - public Param copy() { - Param copy = new Param(); - copy.isInParam = isInParam; - copy.isOutParam = isOutParam; - copy.type = type; - copy.inValue = inValue; - copy.outValue = outValue; - return copy; - } - - public int hashCode() { - int hc = getClass().hashCode(); - hc = hc * 31 + (isInParam ? 0 : 1); - hc = hc * 31 + (isOutParam ? 0 : 1); - hc = hc * 31 + (type); - hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); - return hc; - } + /** + * Construct a Parameter. + */ + public Param() { + } - public boolean equals(Object o) { + public int queryBindCount() { + if (inValue == null) { + return 0; + } + if (inValue instanceof Collection) { + return ((Collection) inValue).size(); + } + return 1; + } + + /** + * Create a deep copy of the Param. + */ + public Param copy() { + Param copy = new Param(); + copy.isInParam = isInParam; + copy.isOutParam = isOutParam; + copy.type = type; + copy.inValue = inValue; + copy.outValue = outValue; + return copy; + } + + public int hashCode() { + int hc = getClass().hashCode(); + hc = hc * 31 + (isInParam ? 0 : 1); + hc = hc * 31 + (isOutParam ? 0 : 1); + hc = hc * 31 + (type); + hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); + return hc; + } + + public boolean equals(Object o) { return o != null && (o == this || (o instanceof Param) && hashCode() == o.hashCode()); } - - /** - * Return true if this is an In parameter that needs to be bound before - * execution. - */ - public boolean isInParam() { - return isInParam; - } - /** - * Return true if this is an out parameter that needs to be registered - * before execution. - */ - public boolean isOutParam() { - return isOutParam; - } + /** + * Return true if this is an In parameter that needs to be bound before + * execution. + */ + public boolean isInParam() { + return isInParam; + } - /** - * Return the jdbc type of this parameter. Used for registering Out - * parameters and setting NULL In parameters. - */ - public int getType() { - return type; - } + /** + * Return true if this is an out parameter that needs to be registered + * before execution. + */ + public boolean isOutParam() { + return isOutParam; + } - /** - * Set the Out parameter type. - */ - public void setOutType(int type) { - this.type = type; - this.isOutParam = true; - } + /** + * Return the jdbc type of this parameter. Used for registering Out + * parameters and setting NULL In parameters. + */ + public int getType() { + return type; + } - /** - * Set the In value. - */ - public void setInValue(Object in) { - this.inValue = in; - this.isInParam = true; - } + /** + * Set the Out parameter type. + */ + public void setOutType(int type) { + this.type = type; + this.isOutParam = true; + } + + /** + * Set the In value. + */ + public void setInValue(Object in) { + this.inValue = in; + this.isInParam = true; + } /** * Set an encryption key (which can not be logged). @@ -458,40 +458,40 @@ public class BindParams implements Serializable { this.isInParam = true; this.encryptionKey = true; } - - /** - * Specify that the In parameter is NULL and the specific type that it - * is. - */ - public void setInNullType(int type) { - this.type = type; - this.inValue = null; - this.isInParam = true; - } - /** - * Return the OUT value that was retrieved. This value is set after - * CallableStatement was executed. - */ - public Object getOutValue() { - return outValue; - } + /** + * Specify that the In parameter is NULL and the specific type that it + * is. + */ + public void setInNullType(int type) { + this.type = type; + this.inValue = null; + this.isInParam = true; + } - /** - * Return the In value. If this is null, then the type should be used to - * specify the type of the null. - */ - public Object getInValue() { - return inValue; - } + /** + * Return the OUT value that was retrieved. This value is set after + * CallableStatement was executed. + */ + public Object getOutValue() { + return outValue; + } - /** - * Set the OUT value returned by a CallableStatement after it has - * executed. - */ - public void setOutValue(Object out) { - this.outValue = out; - } + /** + * Return the In value. If this is null, then the type should be used to + * specify the type of the null. + */ + public Object getInValue() { + return inValue; + } + + /** + * Set the OUT value returned by a CallableStatement after it has + * executed. + */ + public void setOutValue(Object out) { + this.outValue = out; + } /** * If true do not include this value in a transaction log. @@ -500,5 +500,5 @@ public class BindParams implements Serializable { return encryptionKey; } - } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java b/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java index 8e3f0679e..aac90be4c 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java @@ -44,7 +44,7 @@ public class ClassUtil { ClassLoader contextLoader() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); - return (loader != null) ? loader: callerLoader; + return (loader != null) ? loader : callerLoader; } public Class forName(String name) throws ClassNotFoundException { diff --git a/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java b/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java index 2fc8613f7..5de101008 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java @@ -5,13 +5,13 @@ package com.avaje.ebeaninternal.api; */ public enum ConcurrencyMode { - /** - * No concurrency checking. - */ - NONE, - - /** - * Use a version column. - */ - VERSION + /** + * No concurrency checking. + */ + NONE, + + /** + * Use a version column. + */ + VERSION } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java b/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java index a9422ac14..c885b29e2 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java @@ -6,7 +6,7 @@ package com.avaje.ebeaninternal.api; public class HashQuery { private final CQueryPlanKey planHash; - + private final int bindHash; /** @@ -26,7 +26,7 @@ public class HashQuery { hc = 31 * hc + bindHash; return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -34,7 +34,7 @@ public class HashQuery { if (!(obj instanceof HashQuery)) { return false; } - + HashQuery e = (HashQuery) obj; return e.bindHash == bindHash && e.planHash.equals(planHash); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java index d4c75e05d..d7faa080f 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java @@ -6,9 +6,9 @@ package com.avaje.ebeaninternal.api; public class HashQueryPlan { private final String rawSql; - + private final int planHash; - + private final int bindCount; public HashQueryPlan(String rawSql, int planHash, int bindCount) { @@ -18,7 +18,7 @@ public class HashQueryPlan { } public String toString() { - return planHash+":"+bindCount+(rawSql != null ? ":r" : ""); + return planHash + ":" + bindCount + (rawSql != null ? ":r" : ""); } /** @@ -27,7 +27,7 @@ public class HashQueryPlan { * can be used as a shot form proxy for the actual sql. */ public String getPartialKey() { - return planHash+"_"+bindCount; + return planHash + "_" + bindCount; } public int hashCode() { @@ -36,7 +36,7 @@ public class HashQueryPlan { hc = hc * 31 + (rawSql == null ? 0 : rawSql.hashCode()); return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -44,11 +44,11 @@ public class HashQueryPlan { if (!(obj instanceof HashQueryPlan)) { return false; } - + HashQueryPlan e = (HashQueryPlan) obj; //noinspection StringEquality return e.planHash == planHash - && e.bindCount == bindCount - && ((e.rawSql == rawSql) || (e.rawSql != null && e.rawSql.equals(rawSql))); + && e.bindCount == bindCount + && ((e.rawSql == rawSql) || (e.rawSql != null && e.rawSql.equals(rawSql))); } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java index c1f2ad696..e55962625 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java @@ -8,7 +8,7 @@ import java.util.Set; public class HashQueryPlanBuilder { private int planHash; - + private int bindCount; public HashQueryPlanBuilder() { @@ -16,9 +16,9 @@ public class HashQueryPlanBuilder { } public String toString() { - return planHash+":"+bindCount; + return planHash + ":" + bindCount; } - + /** * Add a class to the hash calculation. */ @@ -57,7 +57,7 @@ public class HashQueryPlanBuilder { planHash = planHash * 92821 + (hashValue); return this; } - + /** * Add a boolean to the hash calculation. */ @@ -65,7 +65,7 @@ public class HashQueryPlanBuilder { planHash = planHash * 92821 + (booleanValue ? 92821 : 0); return this; } - + /** * Add a number to the bind count for the hash. */ @@ -83,7 +83,7 @@ public class HashQueryPlanBuilder { * Build and return the calculated HashQueryPlan. */ public String build() { - return planHash+"_"+bindCount; + return planHash + "_" + bindCount; } public int getPlanHash() { diff --git a/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java index abc111d61..2c7978171 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java @@ -9,28 +9,29 @@ import com.avaje.ebean.TxScope; */ public class HelpScopeTrans { - /** - * Create a ScopeTrans for a given methods TxScope. - */ - public static ScopeTrans createScopeTrans(TxScope txScope) { - - EbeanServer server = Ebean.getServer(txScope.getServerName()); - SpiEbeanServer iserver = (SpiEbeanServer)server; - return iserver.createScopeTrans(txScope); - } - - /** - * Exiting the method in an expected fashion. - *

- * That is returning successfully or via a caught exception. - * Unexpected exceptions are caught via the Thread uncaughtExceptionHandler. - *

- * @param returnOrThrowable the return or throwable object - * @param opCode the opcode for ATHROW or ARETURN etc - * @param scopeTrans the scoped transaction the method was run with. - */ - public static void onExitScopeTrans(Object returnOrThrowable, int opCode, ScopeTrans scopeTrans){ - - scopeTrans.onExit(returnOrThrowable, opCode); - } + /** + * Create a ScopeTrans for a given methods TxScope. + */ + public static ScopeTrans createScopeTrans(TxScope txScope) { + + EbeanServer server = Ebean.getServer(txScope.getServerName()); + SpiEbeanServer iserver = (SpiEbeanServer) server; + return iserver.createScopeTrans(txScope); + } + + /** + * Exiting the method in an expected fashion. + *

+ * That is returning successfully or via a caught exception. + * Unexpected exceptions are caught via the Thread uncaughtExceptionHandler. + *

+ * + * @param returnOrThrowable the return or throwable object + * @param opCode the opcode for ATHROW or ARETURN etc + * @param scopeTrans the scoped transaction the method was run with. + */ + public static void onExitScopeTrans(Object returnOrThrowable, int opCode, ScopeTrans scopeTrans) { + + scopeTrans.onExit(returnOrThrowable, opCode); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java index 82e26aa9b..4a90fefa9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.util.List; - import com.avaje.ebean.bean.EntityBeanIntercept; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import java.util.List; + /** * A buffer of beans for batch lazy loading and secondary query loading. */ @@ -14,7 +14,7 @@ public interface LoadBeanBuffer { int getBatchSize(); List getBatch(); - + BeanDescriptor getBeanDescriptor(); PersistenceContext getPersistenceContext(); @@ -23,4 +23,4 @@ public interface LoadBeanBuffer { void configureQuery(SpiQuery query, String lazyLoadProperty); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java index f38b43189..65c9b0ffc 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java @@ -5,6 +5,5 @@ package com.avaje.ebeaninternal.api; * Controls the loading of ManyToOne and OneToOne relationships. */ public interface LoadBeanContext extends LoadSecondaryQuery { - - + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java index 2a66310de..09e796aac 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java @@ -95,11 +95,10 @@ public class LoadBeanRequest extends LoadRequest { */ public List getIdList(int batchSize) { - List idList = new ArrayList(batchSize); + List idList = new ArrayList<>(batchSize); BeanDescriptor desc = loadBuffer.getBeanDescriptor(); - for (int i = 0; i < batch.size(); i++) { - EntityBeanIntercept ebi = batch.get(i); + for (EntityBeanIntercept ebi : batch) { EntityBean bean = ebi.getOwner(); idList.add(desc.getId(bean)); } @@ -150,12 +149,12 @@ public class LoadBeanRequest extends LoadRequest { */ public void postLoad(List list) { - Set loadedIds = new HashSet(); + Set loadedIds = new HashSet<>(); BeanDescriptor desc = loadBuffer.getBeanDescriptor(); // collect Ids and maybe load bean cache - for (int i = 0; i < list.size(); i++) { - EntityBean loadedBean = (EntityBean) list.get(i); + for (Object aList : list) { + EntityBean loadedBean = (EntityBean) aList; loadedIds.add(desc.getId(loadedBean)); if (isLoadCache()) { desc.cacheBeanPut(loadedBean); @@ -163,10 +162,9 @@ public class LoadBeanRequest extends LoadRequest { } if (lazyLoadProperty != null) { - for (int i = 0; i < batch.size(); i++) { + for (EntityBeanIntercept ebi : batch) { // check if the underlying row in DB was deleted. Mark the bean as 'failed' if // necessary but allow processing to continue until it is accessed by client code - EntityBeanIntercept ebi = batch.get(i); Object id = desc.getId(ebi.getOwner()); if (!loadedIds.contains(id)) { if (desc.isSoftDelete()) { diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java index d067559e9..f8d1a1ce3 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.api; -import java.util.List; - import com.avaje.ebean.bean.BeanCollection; import com.avaje.ebean.bean.ObjectGraphNode; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; +import java.util.List; + /** * A buffer of bean collections for batch lazy loading and secondary query loading. */ @@ -16,7 +16,7 @@ public interface LoadManyBuffer { int getBatchSize(); List> getBatch(); - + BeanPropertyAssocMany getBeanProperty(); ObjectGraphNode getObjectGraphNode(); @@ -30,4 +30,4 @@ public interface LoadManyBuffer { void configureQuery(SpiQuery query); boolean isUseDocStore(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java index 4747778af..dd64d2bd9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java @@ -5,5 +5,5 @@ package com.avaje.ebeaninternal.api; * Controls the loading of OneToMany and ManyToMany relationships. */ public interface LoadManyContext extends LoadSecondaryQuery { - + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java index 9c845714d..281939151 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java @@ -42,7 +42,7 @@ public class LoadManyRequest extends LoadRequest { this(loadContext, parentRequest, false, false, false); } - private LoadManyRequest(LoadManyBuffer loadContext, OrmQueryRequest parentRequest, boolean lazy, boolean onlyIds, boolean loadCache) { + private LoadManyRequest(LoadManyBuffer loadContext, OrmQueryRequest parentRequest, boolean lazy, boolean onlyIds, boolean loadCache) { super(parentRequest, lazy); this.loadContext = loadContext; this.batch = loadContext.getBatch(); @@ -101,11 +101,10 @@ public class LoadManyRequest extends LoadRequest { private List getParentIdList(int batchSize) { - ArrayList idList = new ArrayList(batchSize); + ArrayList idList = new ArrayList<>(batchSize); BeanPropertyAssocMany many = getMany(); - for (int i = 0; i < batch.size(); i++) { - BeanCollection bc = batch.get(i); + for (BeanCollection bc : batch) { idList.add(many.getParentId(bc.getOwnerBean())); } int extraIds = batchSize - batch.size(); @@ -177,8 +176,7 @@ public class LoadManyRequest extends LoadRequest { // check for BeanCollection's that where never processed // in the +query or +lazy load due to no rows (predicates) - for (int i = 0; i < batch.size(); i++) { - BeanCollection bc = batch.get(i); + for (BeanCollection bc : batch) { if (bc.checkEmptyLazyLoad()) { if (logger.isDebugEnabled()) { EntityBean ownerBean = bc.getOwnerBean(); diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java index 89c2c7fdf..4220a28f3 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java @@ -14,12 +14,12 @@ public abstract class LoadRequest { protected final boolean lazy; - public LoadRequest(OrmQueryRequest parentRequest, boolean lazy) { + public LoadRequest(OrmQueryRequest parentRequest, boolean lazy) { - this.parentRequest = parentRequest; - this.transaction = parentRequest == null ? null : parentRequest.getTransaction(); - this.lazy = lazy; - } + this.parentRequest = parentRequest; + this.transaction = parentRequest == null ? null : parentRequest.getTransaction(); + this.lazy = lazy; + } /** * Return the associated bean type for this load request. @@ -35,29 +35,29 @@ public abstract class LoadRequest { parentRequest.getQuery().logSecondaryQuery(query); } } - - /** - * Return true if this is a lazy load and false if it is a secondary query. - */ - public boolean isLazy() { - return lazy; - } - /** - * Return the transaction to use if this is a secondary query. - *

- * Lazy loading queries run in their own transaction. - *

- */ - public Transaction getTransaction() { - return transaction; - } + /** + * Return true if this is a lazy load and false if it is a secondary query. + */ + public boolean isLazy() { + return lazy; + } - /** - * Return true if the parent query is a findIterate() type query. - * So one of - findIterate(), findEach(), findEachWhile() or findVisit(). - */ - public boolean isParentFindIterate() { - return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE; - } + /** + * Return the transaction to use if this is a secondary query. + *

+ * Lazy loading queries run in their own transaction. + *

+ */ + public Transaction getTransaction() { + return transaction; + } + + /** + * Return true if the parent query is a findIterate() type query. + * So one of - findIterate(), findEach(), findEachWhile() or findVisit(). + */ + public boolean isParentFindIterate() { + return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java b/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java index bb97cccca..317409f45 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java @@ -11,8 +11,8 @@ import com.avaje.ebeaninternal.server.core.OrmQueryRequest; */ public interface LoadSecondaryQuery { - /** - * Execute the secondary query with a given batch size. - */ - void loadSecondaryQuery(OrmQueryRequest parentRequest, boolean forEach); + /** + * Execute the secondary query with a given batch size. + */ + void loadSecondaryQuery(OrmQueryRequest parentRequest, boolean forEach); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java b/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java index 1a1519b4c..41b9f9540 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java @@ -19,7 +19,7 @@ public class ManyWhereJoins implements Serializable { private static final long serialVersionUID = -6490181101871795417L; - private final TreeMap joins = new TreeMap(); + private final TreeMap joins = new TreeMap<>(); private StringBuilder formulaProperties = new StringBuilder(); @@ -113,7 +113,7 @@ public class ManyWhereJoins implements Serializable { */ public TreeSet getPropertyNames() { - TreeSet propertyNames = new TreeSet(); + TreeSet propertyNames = new TreeSet<>(); for (PropertyJoin join : joins.values()) { propertyNames.add(join.getProperty()); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/Monitor.java b/src/main/java/com/avaje/ebeaninternal/api/Monitor.java index 3a2e8221c..86aac0370 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/Monitor.java +++ b/src/main/java/com/avaje/ebeaninternal/api/Monitor.java @@ -7,6 +7,6 @@ import java.io.Serializable; */ public class Monitor implements Serializable { - private static final long serialVersionUID = -2741687226680981940L; - + private static final long serialVersionUID = -2741687226680981940L; + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java b/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java index 2b183074c..0b9338ed9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java @@ -11,7 +11,7 @@ public class PropertyJoin { * The property name. */ private final String property; - + /** * Set to true if the property needs to be an outer join. */ @@ -35,5 +35,5 @@ public class PropertyJoin { public SqlJoinType getSqlJoinType() { return joinType; } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java index c2eda8690..734099800 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java @@ -221,8 +221,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { } if (noRollbackFor != null) { - for (int i = 0; i < noRollbackFor.size(); i++) { - if (noRollbackFor.get(i).equals(e.getClass())) { + for (Class aNoRollbackFor : noRollbackFor) { + if (aNoRollbackFor.equals(e.getClass())) { // explicit no rollback for this one return false; @@ -231,8 +231,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { } if (rollbackFor != null) { - for (int i = 0; i < rollbackFor.size(); i++) { - if (rollbackFor.get(i).equals(e.getClass())) { + for (Class aRollbackFor : rollbackFor) { + if (aRollbackFor.equals(e.getClass())) { // explicit rollback for this one return true; } diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java index 735675c58..85bc3fd89 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java @@ -6,9 +6,9 @@ import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebean.config.PersistBatch; import com.avaje.ebean.event.changelog.BeanChange; import com.avaje.ebean.event.changelog.ChangeSet; +import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.persist.BatchControl; import javax.persistence.PersistenceException; @@ -369,6 +369,11 @@ public class ScopedTransaction implements SpiTransaction { transaction.flushBatchOnCascade(); } + @Override + public void flushBatchOnRollback() { + transaction.flushBatchOnRollback(); + } + @Override public void markNotQueryOnly() { transaction.markNotQueryOnly(); diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java b/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java index c4bf5f744..3619b9349 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java @@ -7,8 +7,8 @@ import com.avaje.ebean.BackgroundExecutor; */ public interface SpiBackgroundExecutor extends BackgroundExecutor { - /** - * Shutdown any associated thread pools. - */ - void shutdown(); + /** + * Shutdown any associated thread pools. + */ + void shutdown(); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java b/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java index 152492c26..2afa43159 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java @@ -4,7 +4,7 @@ import com.avaje.ebean.CallableSql; public interface SpiCallableSql extends CallableSql { - BindParams getBindParams(); - - TransactionEventTable getTransactionEventTable(); + BindParams getBindParams(); + + TransactionEventTable getTransactionEventTable(); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java index cc98af802..09e02d717 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java @@ -13,10 +13,10 @@ import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.dbplatform.DatabasePlatform; import com.avaje.ebean.event.readaudit.ReadAuditLogger; import com.avaje.ebean.event.readaudit.ReadAuditPrepare; +import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.query.CQuery; import com.avaje.ebeaninternal.server.transaction.RemoteTransactionEvent; -import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import java.util.List; @@ -145,7 +145,7 @@ public interface SpiEbeanServer extends EbeanServer, BeanLoader, BeanCollectionL * the query has finished (if executing in a background thread). *

*/ - List findIdsWithCopy(Query query, Transaction t); + List findIdsWithCopy(Query query, Transaction t); /** * Execute the findRowCount query but without copying the query. diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java index 0c996e741..7195d79e7 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java @@ -13,28 +13,28 @@ import java.io.IOException; */ public interface SpiExpression extends Expression { - /** - * Simplify nested expressions if possible. - */ - void simplify(); + /** + * Simplify nested expressions if possible. + */ + void simplify(); - /** + /** * Write the expression as an elastic search expression. */ void writeDocQuery(DocQueryContext context) throws IOException; - /** - * Return the nested path for this expression. - */ - String nestedPath(BeanDescriptor desc); + /** + * Return the nested path for this expression. + */ + String nestedPath(BeanDescriptor desc); - /** - * Process "Many" properties populating ManyWhereJoins. + /** + * Process "Many" properties populating ManyWhereJoins. *

* Predicates on Many properties require an extra independent join clause. *

*/ - void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins); + void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins); /** * Prepare the expression. For example, compile sub-query expressions etc. @@ -42,18 +42,18 @@ public interface SpiExpression extends Expression { void prepareExpression(BeanQueryRequest request); /** - * Calculate a hash value used to identify a query for AutoTune tuning. - *

- * That is, if the hash changes then the query will be considered different - * from an AutoTune perspective and get different tuning. - *

- */ - void queryPlanHash(HashQueryPlanBuilder builder); + * Calculate a hash value used to identify a query for AutoTune tuning. + *

+ * That is, if the hash changes then the query will be considered different + * from an AutoTune perspective and get different tuning. + *

+ */ + void queryPlanHash(HashQueryPlanBuilder builder); - /** - * Return the hash value for the values that will be bound. - */ - int queryBindHash(); + /** + * Return the hash value for the values that will be bound. + */ + int queryBindHash(); /** * Return true if the expression is the same without taking into account bind values. @@ -65,29 +65,28 @@ public interface SpiExpression extends Expression { */ boolean isSameByBind(SpiExpression other); - /** - * Add some sql to the query. - *

- * This will contain ? as a place holder for each associated bind values. - *

- *

- * The 'sql' added to the query can contain object property names rather - * than db tables and columns. This 'sql' is later parsed converting the - * logical property names to their full database column names. - *

- * @param request - * the associated request. - */ - void addSql(SpiExpressionRequest request); + /** + * Add some sql to the query. + *

+ * This will contain ? as a place holder for each associated bind values. + *

+ *

+ * The 'sql' added to the query can contain object property names rather + * than db tables and columns. This 'sql' is later parsed converting the + * logical property names to their full database column names. + *

+ * + * @param request the associated request. + */ + void addSql(SpiExpressionRequest request); - /** - * Add the parameter values to be set against query. For each ? place holder - * there should be a corresponding value that is added to the bindList. - * - * @param request - * the associated request. - */ - void addBindValues(SpiExpressionRequest request); + /** + * Add the parameter values to be set against query. For each ? place holder + * there should be a corresponding value that is added to the bindList. + * + * @param request the associated request. + */ + void addBindValues(SpiExpressionRequest request); /** * Validate all the properties/paths associated with this expression. @@ -99,8 +98,8 @@ public interface SpiExpression extends Expression { */ SpiExpression copyForPlanKey(); - /** - * Return the bind Id value if this is a "equal to" expression for the id property. + /** + * Return the bind Id value if this is a "equal to" expression for the id property. */ - Object getIdEqualTo(String idName); + Object getIdEqualTo(String idName); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java index c035d1b55..895b81203 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java @@ -1,6 +1,7 @@ package com.avaje.ebeaninternal.api; import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.Junction; import com.avaje.ebeaninternal.server.expression.DocQueryContext; import java.io.IOException; @@ -11,20 +12,25 @@ import java.util.List; */ public interface SpiExpressionList extends ExpressionList, SpiExpression { + /** + * Return the expression list as a Junction (for ElasticSearch). + */ + Junction toJunction(); + /** * Return the underlying list of expressions. */ List getUnderlyingList(); - + /** * Return a copy of the ExpressionList with the path trimmed for filterMany() expressions. */ SpiExpressionList trimPath(int prefixTrim); - - /** - * Return true if this list is empty. - */ - boolean isEmpty(); + + /** + * Return true if this list is empty. + */ + boolean isEmpty(); /** * Write the top level where expressions taking into account possible extra idEquals expression. diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java index 3e0b4e0da..1b0cdb24e 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java @@ -12,7 +12,7 @@ public class SpiExpressionValidation { private final BeanType desc; - private final LinkedHashSet unknown = new LinkedHashSet(); + private final LinkedHashSet unknown = new LinkedHashSet<>(); public SpiExpressionValidation(BeanType desc) { this.desc = desc; diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java index b0254617b..d963fcbfe 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java @@ -166,6 +166,11 @@ public interface SpiQuery extends Query { */ PersistenceContextScope getPersistenceContextScope(); + /** + * Return the origin key. + */ + String getOriginKey(); + /** * Return the default lazy load batch size. */ diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java index 292d47bf3..99c81f2ec 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.api; -import java.sql.PreparedStatement; - import com.avaje.ebean.SqlQuery; /** @@ -39,9 +37,4 @@ public interface SpiSqlQuery extends SqlQuery { */ int getBufferFetchSizeHint(); - /** - * Set the PreparedStatement for the purposes of supporting cancel. - */ - void setPreparedStatement(PreparedStatement pstmt); - } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java index 2060a9c9a..b19ce0b9d 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java @@ -4,7 +4,7 @@ import com.avaje.ebean.SqlUpdate; public interface SpiSqlUpdate extends SqlUpdate { - BindParams getBindParams(); + BindParams getBindParams(); void setGeneratedSql(String sql); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java index 1a22bfb66..e63071432 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java @@ -5,9 +5,9 @@ import com.avaje.ebean.annotation.DocStoreMode; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebean.event.changelog.BeanChange; import com.avaje.ebean.event.changelog.ChangeSet; +import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.persist.BatchControl; import java.sql.Connection; @@ -117,6 +117,7 @@ public interface SpiTransaction extends Transaction { * Returning 0 implies to use the system wide default batch size. *

*/ + @Override int getBatchSize(); /** @@ -235,6 +236,11 @@ public interface SpiTransaction extends Transaction { */ void flushBatchOnCascade(); + /** + * If batch was on then effectively clear the batch such that we can handle exceptions and continue. + */ + void flushBatchOnRollback(); + /** * Mark the transaction explicitly as not being query only. */ diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java index 881b32c49..32a316338 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java @@ -2,5 +2,5 @@ package com.avaje.ebeaninternal.api; public interface SpiTransactionScopeManager { - void replace(SpiTransaction t); + void replace(SpiTransaction t); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java index 04d7be2b9..17324e507 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java @@ -7,70 +7,70 @@ import com.avaje.ebean.Update; */ public interface SpiUpdate extends Update { - /** - * The type of the update request. - */ - enum OrmUpdateType { - INSERT { - public String toString() { - return "Insert"; - } - }, - UPDATE { - public String toString() { - return "Update"; - } - }, - DELETE { - public String toString() { - return "Delete"; - } - }, - UNKNOWN { - public String toString() { - return "Unknown"; - } + /** + * The type of the update request. + */ + enum OrmUpdateType { + INSERT { + public String toString() { + return "Insert"; + } + }, + UPDATE { + public String toString() { + return "Update"; + } + }, + DELETE { + public String toString() { + return "Delete"; + } + }, + UNKNOWN { + public String toString() { + return "Unknown"; + } - } - } - - /** - * Return the type of bean being updated. - */ - Class getBeanType(); + } + } - /** - * Return the type of this - insert, update or delete. - */ - OrmUpdateType getOrmUpdateType(); - - /** - * Return the name of the table being modified. - */ - String getBaseTable(); - - /** - * Return the update statement. This could be either sql or an orm update with bean types and property names. - */ - String getUpdateStatement(); - - /** - * Return the timeout in seconds. - */ - int getTimeout(); - - /** - * Return true if the cache should be notified to invalidate objects. - */ - boolean isNotifyCache(); - - /** - * Return the bind parameters. - */ - BindParams getBindParams(); - - /** - * Set the generated sql used. - */ - void setGeneratedSql(String sql); + /** + * Return the type of bean being updated. + */ + Class getBeanType(); + + /** + * Return the type of this - insert, update or delete. + */ + OrmUpdateType getOrmUpdateType(); + + /** + * Return the name of the table being modified. + */ + String getBaseTable(); + + /** + * Return the update statement. This could be either sql or an orm update with bean types and property names. + */ + String getUpdateStatement(); + + /** + * Return the timeout in seconds. + */ + int getTimeout(); + + /** + * Return true if the cache should be notified to invalidate objects. + */ + boolean isNotifyCache(); + + /** + * Return the bind parameters. + */ + BindParams getBindParams(); + + /** + * Set the generated sql used. + */ + void setGeneratedSql(String sql); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java index 15551602b..1f634a33f 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.sql.SQLException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.persist.dml.DmlHandler; import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; +import java.sql.SQLException; + /** * A plan for executing bean updates for a given set of changed properties. *

@@ -26,41 +26,41 @@ public interface SpiUpdatePlan { *

*/ boolean isEmptySetClause(); - - /** - * Bind given the request and bean. The bean could be the oldValues bean - * when binding a update or delete where clause with ALL concurrency mode. - */ - void bindSet(DmlHandler bind, EntityBean bean) throws SQLException; - /** - * Return the time this plan was created. - */ - long getTimeCreated(); + /** + * Bind given the request and bean. The bean could be the oldValues bean + * when binding a update or delete where clause with ALL concurrency mode. + */ + void bindSet(DmlHandler bind, EntityBean bean) throws SQLException; - /** - * Return the time this plan was last used. - */ - Long getTimeLastUsed(); + /** + * Return the time this plan was created. + */ + long getTimeCreated(); - /** - * Return the hash key for this plan. - */ - Integer getKey(); + /** + * Return the time this plan was last used. + */ + Long getTimeLastUsed(); - /** - * Return the concurrency mode for this plan. - */ - ConcurrencyMode getMode(); + /** + * Return the hash key for this plan. + */ + Integer getKey(); - /** - * Return the update SQL statement. - */ - String getSql(); + /** + * Return the concurrency mode for this plan. + */ + ConcurrencyMode getMode(); - /** - * Return the set of bindable update properties. - */ - Bindable getSet(); + /** + * Return the update SQL statement. + */ + String getSql(); -} \ No newline at end of file + /** + * Return the set of bindable update properties. + */ + Bindable getSet(); + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java index 845431bb5..2f1d0a2f9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java @@ -1,10 +1,10 @@ package com.avaje.ebeaninternal.api; import com.avaje.ebeaninternal.server.cache.CacheChangeSet; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.transaction.DeleteByIdMap; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import java.io.Serializable; import java.util.List; @@ -126,8 +126,8 @@ public class TransactionEvent implements Serializable { List> persistRequestBeans = getPersistRequestBeans(); if (persistRequestBeans != null) { - for (int i=0; i< persistRequestBeans.size(); i++) { - persistRequestBeans.get(i).addDocStoreUpdates(docStoreUpdates); + for (PersistRequestBean persistRequestBean : persistRequestBeans) { + persistRequestBean.addDocStoreUpdates(docStoreUpdates); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java index 4bfd565ae..608091511 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.server.cache.CacheChangeSet; import com.avaje.ebeaninternal.server.core.PersistRequestBean; +import java.util.ArrayList; +import java.util.List; + /** * Lists of inserted updated and deleted beans that have a BeanPersistListener. *

@@ -15,30 +15,30 @@ import com.avaje.ebeaninternal.server.core.PersistRequestBean; */ public class TransactionEventBeans { - final ArrayList> requests = new ArrayList>(); + final ArrayList> requests = new ArrayList<>(); - /** - * Return the list of PersistRequests that BeanListeners are interested in. - */ - public List> getRequests() { - return requests; - } - - /** - * Add a bean for BeanListener notification. - */ - public void add(PersistRequestBean request) { - - requests.add(request); - } - - /** - * Collect the cache changes. + /** + * Return the list of PersistRequests that BeanListeners are interested in. */ - public void notifyCache(CacheChangeSet changeSet) { - for (int i = 0; i < requests.size(); i++) { - requests.get(i).notifyCache(changeSet); - } - } + public List> getRequests() { + return requests; + } + + /** + * Add a bean for BeanListener notification. + */ + public void add(PersistRequestBean request) { + + requests.add(request); + } + + /** + * Collect the cache changes. + */ + public void notifyCache(CacheChangeSet changeSet) { + for (PersistRequestBean request : requests) { + request.notifyCache(changeSet); + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java index 08d50ee82..c96580f4a 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java @@ -1,5 +1,9 @@ package com.avaje.ebeaninternal.api; +import com.avaje.ebean.event.BulkTableEvent; +import com.avaje.ebeaninternal.server.cluster.BinaryMessage; +import com.avaje.ebeaninternal.server.cluster.BinaryMessageList; + import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; @@ -8,136 +12,133 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import com.avaje.ebean.event.BulkTableEvent; -import com.avaje.ebeaninternal.server.cluster.BinaryMessage; -import com.avaje.ebeaninternal.server.cluster.BinaryMessageList; - public final class TransactionEventTable implements Serializable { - private static final long serialVersionUID = 2236555729767483264L; - - private final Map map = new HashMap(); - - public String toString() { - return "TransactionEventTable " + map.values(); + private static final long serialVersionUID = 2236555729767483264L; + + private final Map map = new HashMap<>(); + + public String toString() { + return "TransactionEventTable " + map.values(); + } + + public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { + + for (TableIUD tableIud : map.values()) { + tableIud.writeBinaryMessage(msgList); + } + } + + public void readBinaryMessage(DataInput dataInput) throws IOException { + + TableIUD tableIud = TableIUD.readBinaryMessage(dataInput); + map.put(tableIud.getTableName(), tableIud); + } + + + public void add(TransactionEventTable table) { + + for (TableIUD iud : table.values()) { + add(iud); + } + } + + public void add(String table, boolean insert, boolean update, boolean delete) { + + table = table.toUpperCase(); + + add(new TableIUD(table, insert, update, delete)); + } + + public void add(TableIUD newTableIUD) { + + TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD); + if (existingTableIUD != null) { + newTableIUD.add(existingTableIUD); + } + } + + public boolean isEmpty() { + return map.isEmpty(); + } + + public Collection values() { + return map.values(); + } + + public static class TableIUD implements Serializable, BulkTableEvent { + + private static final long serialVersionUID = -1958317571064162089L; + + private final String table; + private boolean insert; + private boolean update; + private boolean delete; + + public TableIUD(String table, boolean insert, boolean update, boolean delete) { + this.table = table; + this.insert = insert; + this.update = update; + this.delete = delete; + } + + public static TableIUD readBinaryMessage(DataInput dataInput) throws IOException { + + String table = dataInput.readUTF(); + boolean insert = dataInput.readBoolean(); + boolean update = dataInput.readBoolean(); + boolean delete = dataInput.readBoolean(); + + return new TableIUD(table, insert, update, delete); } public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { - for (TableIUD tableIud : map.values()) { - tableIud.writeBinaryMessage(msgList); - } - } - - public void readBinaryMessage(DataInput dataInput) throws IOException { - - TableIUD tableIud = TableIUD.readBinaryMessage(dataInput); - map.put(tableIud.getTableName(), tableIud); + BinaryMessage msg = new BinaryMessage(table.length() + 10); + DataOutputStream os = msg.getOs(); + os.writeInt(BinaryMessage.TYPE_TABLEIUD); + os.writeUTF(table); + os.writeBoolean(insert); + os.writeBoolean(update); + os.writeBoolean(delete); + + msgList.add(msg); } - - public void add(TransactionEventTable table){ - - for (TableIUD iud : table.values()) { - add(iud); - } - } + public String toString() { + return "TableIUD " + table + " i:" + insert + " u:" + update + " d:" + delete; + } - public void add(String table, boolean insert, boolean update, boolean delete){ + private void add(TableIUD other) { + if (other.insert) { + insert = true; + } + if (other.update) { + update = true; + } + if (other.delete) { + delete = true; + } + } - table = table.toUpperCase(); - - add(new TableIUD(table, insert, update, delete)); - } - - public void add(TableIUD newTableIUD){ + public String getTableName() { + return table; + } - TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD); - if (existingTableIUD != null){ - newTableIUD.add(existingTableIUD); - } - } - - public boolean isEmpty() { - return map.isEmpty(); - } - - public Collection values() { - return map.values(); - } - - public static class TableIUD implements Serializable, BulkTableEvent { - - private static final long serialVersionUID = -1958317571064162089L; - - private final String table; - private boolean insert; - private boolean update; - private boolean delete; - - public TableIUD(String table, boolean insert, boolean update, boolean delete){ - this.table = table; - this.insert = insert; - this.update = update; - this.delete = delete; - } - - public static TableIUD readBinaryMessage(DataInput dataInput) throws IOException { - - String table = dataInput.readUTF(); - boolean insert = dataInput.readBoolean(); - boolean update = dataInput.readBoolean(); - boolean delete = dataInput.readBoolean(); - - return new TableIUD(table, insert, update, delete); - } - - public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { - - BinaryMessage msg = new BinaryMessage(table.length()+10); - DataOutputStream os = msg.getOs(); - os.writeInt(BinaryMessage.TYPE_TABLEIUD); - os.writeUTF(table); - os.writeBoolean(insert); - os.writeBoolean(update); - os.writeBoolean(delete); - - msgList.add(msg); - } - - public String toString() { - return "TableIUD "+table+" i:"+insert+" u:"+update+" d:"+delete; - } - - private void add(TableIUD other) { - if (other.insert){ - insert = true; - } - if (other.update){ - update = true; - } - if (other.delete){ - delete = true; - } - } - public String getTableName() { - return table; - } + public boolean isInsert() { + return insert; + } - public boolean isInsert() { - return insert; - } + public boolean isUpdate() { + return update; + } - public boolean isUpdate() { - return update; - } + public boolean isDelete() { + return delete; + } - public boolean isDelete() { - return delete; - } - - public boolean isUpdateOrDelete() { - return update || delete; - } - } + public boolean isUpdateOrDelete() { + return update || delete; + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java index a0020f584..fd104ac5a 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.extraddl.model; import javax.xml.bind.annotation.XmlAccessType; @@ -11,9 +10,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <simpleContent>
@@ -24,93 +23,79 @@ import javax.xml.bind.annotation.XmlValue;
  *   </simpleContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "value" + "value" }) @XmlRootElement(name = "ddl-script") public class DdlScript { - @XmlValue - protected String value; - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "platforms") - protected String platforms; + @XmlValue + protected String value; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "platforms") + protected String platforms; - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() { + return value; + } - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) { + this.value = value; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the platforms property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPlatforms() { - return platforms; - } + /** + * Gets the value of the platforms property. + * + * @return possible object is + * {@link String } + */ + public String getPlatforms() { + return platforms; + } - /** - * Sets the value of the platforms property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPlatforms(String value) { - this.platforms = value; - } + /** + * Sets the value of the platforms property. + * + * @param value allowed object is + * {@link String } + */ + public void setPlatforms(String value) { + this.platforms = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java index 23a9c4b9f..3c7867262 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java @@ -1,20 +1,19 @@ - package com.avaje.ebeaninternal.extraddl.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,46 +25,42 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "ddlScript" + "ddlScript" }) @XmlRootElement(name = "extra-ddl") public class ExtraDdl { - @XmlElement(name = "ddl-script", required = true) - protected List ddlScript; + @XmlElement(name = "ddl-script", required = true) + protected List ddlScript; - /** - * Gets the value of the ddlScript property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the ddlScript property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getDdlScript().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link DdlScript } - * - * - */ - public List getDdlScript() { - if (ddlScript == null) { - ddlScript = new ArrayList(); - } - return this.ddlScript; + /** + * Gets the value of the ddlScript property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the ddlScript property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getDdlScript().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link DdlScript } + */ + public List getDdlScript() { + if (ddlScript == null) { + ddlScript = new ArrayList<>(); } + return this.ddlScript; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java index 2a3767785..1a5e1fbf0 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java @@ -36,8 +36,9 @@ public class ExtraDdlXmlReader { /** * Return true if the script platforms is a match/supported for the given platform. + * * @param platformName The database platform we are generating/running DDL for - * @param platforms The platforms (comma delimited) this script should run for + * @param platforms The platforms (comma delimited) this script should run for */ public static boolean matchPlatform(String platformName, String platforms) { if (platforms == null || platforms.trim().isEmpty()) { diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java index 07009ef1a..c73abca6f 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java @@ -1,48 +1,43 @@ - package com.avaje.ebeaninternal.extraddl.model; import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.avaje.ebeaninternal.extraddl.model package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.avaje.ebeaninternal.extraddl.model package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * */ @XmlRegistry public class ObjectFactory { - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.extraddl.model - * - */ - public ObjectFactory() { - } + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.extraddl.model + */ + public ObjectFactory() { + } - /** - * Create an instance of {@link DdlScript } - * - */ - public DdlScript createDdlScript() { - return new DdlScript(); - } + /** + * Create an instance of {@link DdlScript } + */ + public DdlScript createDdlScript() { + return new DdlScript(); + } - /** - * Create an instance of {@link ExtraDdl } - * - */ - public ExtraDdl createExtraDdl() { - return new ExtraDdl(); - } + /** + * Create an instance of {@link ExtraDdl } + */ + public ExtraDdl createExtraDdl() { + return new ExtraDdl(); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/AutoTuneCollection.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/AutoTuneCollection.java index 0f90d116b..61658145f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/AutoTuneCollection.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/AutoTuneCollection.java @@ -11,7 +11,7 @@ import java.util.List; */ public class AutoTuneCollection { - List entries = new ArrayList(); + List entries = new ArrayList<>(); public Entry add(ObjectGraphOrigin origin, OrmQueryDetail detail, String sourceQuery) { Entry entry = new Entry(origin, detail, sourceQuery); @@ -46,7 +46,7 @@ public class AutoTuneCollection { /** * Summary execution statistics for queries related to this origin point. */ - private final List queries = new ArrayList(); + private final List queries = new ArrayList<>(); public Entry(ObjectGraphOrigin origin, OrmQueryDetail detail, String originalQuery) { this.origin = origin; diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java index 68bd3c7fd..c9c67c248 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java @@ -1,19 +1,18 @@ - package com.avaje.ebeaninternal.server.autotune.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * + * Java class for anonymous complex type. + *

+ * The following schema fragment specifies the expected content contained within this class. + *

*

  * <complexType>
  *   <complexContent>
@@ -28,123 +27,107 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "origin", - "profileDiff", - "profileNew", - "profileEmpty" + "origin", + "profileDiff", + "profileNew", + "profileEmpty" }) @XmlRootElement(name = "autotune") public class Autotune { - protected List origin; - protected ProfileDiff profileDiff; - protected ProfileNew profileNew; - protected ProfileEmpty profileEmpty; + protected List origin; + protected ProfileDiff profileDiff; + protected ProfileNew profileNew; + protected ProfileEmpty profileEmpty; - /** - * Gets the value of the origin property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the origin property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getOrigin().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Origin } - * - * - */ - public List getOrigin() { - if (origin == null) { - origin = new ArrayList(); - } - return this.origin; + /** + * Gets the value of the origin property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the origin property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getOrigin().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Origin } + */ + public List getOrigin() { + if (origin == null) { + origin = new ArrayList<>(); } + return this.origin; + } - /** - * Gets the value of the profileDiff property. - * - * @return - * possible object is - * {@link ProfileDiff } - * - */ - public ProfileDiff getProfileDiff() { - return profileDiff; - } + /** + * Gets the value of the profileDiff property. + * + * @return possible object is + * {@link ProfileDiff } + */ + public ProfileDiff getProfileDiff() { + return profileDiff; + } - /** - * Sets the value of the profileDiff property. - * - * @param value - * allowed object is - * {@link ProfileDiff } - * - */ - public void setProfileDiff(ProfileDiff value) { - this.profileDiff = value; - } + /** + * Sets the value of the profileDiff property. + * + * @param value allowed object is + * {@link ProfileDiff } + */ + public void setProfileDiff(ProfileDiff value) { + this.profileDiff = value; + } - /** - * Gets the value of the profileNew property. - * - * @return - * possible object is - * {@link ProfileNew } - * - */ - public ProfileNew getProfileNew() { - return profileNew; - } + /** + * Gets the value of the profileNew property. + * + * @return possible object is + * {@link ProfileNew } + */ + public ProfileNew getProfileNew() { + return profileNew; + } - /** - * Sets the value of the profileNew property. - * - * @param value - * allowed object is - * {@link ProfileNew } - * - */ - public void setProfileNew(ProfileNew value) { - this.profileNew = value; - } + /** + * Sets the value of the profileNew property. + * + * @param value allowed object is + * {@link ProfileNew } + */ + public void setProfileNew(ProfileNew value) { + this.profileNew = value; + } - /** - * Gets the value of the profileEmpty property. - * - * @return - * possible object is - * {@link ProfileEmpty } - * - */ - public ProfileEmpty getProfileEmpty() { - return profileEmpty; - } + /** + * Gets the value of the profileEmpty property. + * + * @return possible object is + * {@link ProfileEmpty } + */ + public ProfileEmpty getProfileEmpty() { + return profileEmpty; + } - /** - * Sets the value of the profileEmpty property. - * - * @param value - * allowed object is - * {@link ProfileEmpty } - * - */ - public void setProfileEmpty(ProfileEmpty value) { - this.profileEmpty = value; - } + /** + * Sets the value of the profileEmpty property. + * + * @param value allowed object is + * {@link ProfileEmpty } + */ + public void setProfileEmpty(ProfileEmpty value) { + this.profileEmpty = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ObjectFactory.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ObjectFactory.java index effa06fff..26e70bd70 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ObjectFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ObjectFactory.java @@ -1,72 +1,64 @@ - package com.avaje.ebeaninternal.server.autotune.model; import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.avaje.ebeaninternal.server.autotune.model package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.avaje.ebeaninternal.server.autotune.model package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * */ @XmlRegistry public class ObjectFactory { - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.server.autotune.model - * - */ - public ObjectFactory() { - } + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.server.autotune.model + */ + public ObjectFactory() { + } - /** - * Create an instance of {@link ProfileNew } - * - */ - public ProfileNew createProfileNew() { - return new ProfileNew(); - } + /** + * Create an instance of {@link ProfileNew } + */ + public ProfileNew createProfileNew() { + return new ProfileNew(); + } - /** - * Create an instance of {@link Origin } - * - */ - public Origin createOrigin() { - return new Origin(); - } + /** + * Create an instance of {@link Origin } + */ + public Origin createOrigin() { + return new Origin(); + } - /** - * Create an instance of {@link ProfileEmpty } - * - */ - public ProfileEmpty createProfileEmpty() { - return new ProfileEmpty(); - } + /** + * Create an instance of {@link ProfileEmpty } + */ + public ProfileEmpty createProfileEmpty() { + return new ProfileEmpty(); + } - /** - * Create an instance of {@link Autotune } - * - */ - public Autotune createAutotune() { - return new Autotune(); - } + /** + * Create an instance of {@link Autotune } + */ + public Autotune createAutotune() { + return new Autotune(); + } - /** - * Create an instance of {@link ProfileDiff } - * - */ - public ProfileDiff createProfileDiff() { - return new ProfileDiff(); - } + /** + * Create an instance of {@link ProfileDiff } + */ + public ProfileDiff createProfileDiff() { + return new ProfileDiff(); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Origin.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Origin.java index 04c9af034..150197c3b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Origin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Origin.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.server.autotune.model; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -28,144 +27,122 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "callStack" + "callStack" }) @XmlRootElement(name = "origin") public class Origin { - protected String callStack; - @XmlAttribute(name = "key", required = true) - protected String key; - @XmlAttribute(name = "beanType") - protected String beanType; - @XmlAttribute(name = "detail") - protected String detail; - @XmlAttribute(name = "original") - protected String original; + protected String callStack; + @XmlAttribute(name = "key", required = true) + protected String key; + @XmlAttribute(name = "beanType") + protected String beanType; + @XmlAttribute(name = "detail") + protected String detail; + @XmlAttribute(name = "original") + protected String original; - /** - * Gets the value of the callStack property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCallStack() { - return callStack; - } + /** + * Gets the value of the callStack property. + * + * @return possible object is + * {@link String } + */ + public String getCallStack() { + return callStack; + } - /** - * Sets the value of the callStack property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCallStack(String value) { - this.callStack = value; - } + /** + * Sets the value of the callStack property. + * + * @param value allowed object is + * {@link String } + */ + public void setCallStack(String value) { + this.callStack = value; + } - /** - * Gets the value of the key property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getKey() { - return key; - } + /** + * Gets the value of the key property. + * + * @return possible object is + * {@link String } + */ + public String getKey() { + return key; + } - /** - * Sets the value of the key property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setKey(String value) { - this.key = value; - } + /** + * Sets the value of the key property. + * + * @param value allowed object is + * {@link String } + */ + public void setKey(String value) { + this.key = value; + } - /** - * Gets the value of the beanType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBeanType() { - return beanType; - } + /** + * Gets the value of the beanType property. + * + * @return possible object is + * {@link String } + */ + public String getBeanType() { + return beanType; + } - /** - * Sets the value of the beanType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBeanType(String value) { - this.beanType = value; - } + /** + * Sets the value of the beanType property. + * + * @param value allowed object is + * {@link String } + */ + public void setBeanType(String value) { + this.beanType = value; + } - /** - * Gets the value of the detail property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDetail() { - return detail; - } + /** + * Gets the value of the detail property. + * + * @return possible object is + * {@link String } + */ + public String getDetail() { + return detail; + } - /** - * Sets the value of the detail property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDetail(String value) { - this.detail = value; - } + /** + * Sets the value of the detail property. + * + * @param value allowed object is + * {@link String } + */ + public void setDetail(String value) { + this.detail = value; + } - /** - * Gets the value of the original property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOriginal() { - return original; - } + /** + * Gets the value of the original property. + * + * @return possible object is + * {@link String } + */ + public String getOriginal() { + return original; + } - /** - * Sets the value of the original property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOriginal(String value) { - this.original = value; - } + /** + * Sets the value of the original property. + * + * @param value allowed object is + * {@link String } + */ + public void setOriginal(String value) { + this.original = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java index 4bdf73c57..5fc587ef0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java @@ -1,19 +1,18 @@ - package com.avaje.ebeaninternal.server.autotune.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,45 +24,41 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "origin" + "origin" }) @XmlRootElement(name = "profileDiff") public class ProfileDiff { - protected List origin; + protected List origin; - /** - * Gets the value of the origin property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the origin property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getOrigin().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Origin } - * - * - */ - public List getOrigin() { - if (origin == null) { - origin = new ArrayList(); - } - return this.origin; + /** + * Gets the value of the origin property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the origin property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getOrigin().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Origin } + */ + public List getOrigin() { + if (origin == null) { + origin = new ArrayList<>(); } + return this.origin; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java index 0b0dc7eb1..1a962316c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java @@ -1,19 +1,18 @@ - package com.avaje.ebeaninternal.server.autotune.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,45 +24,41 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "origin" + "origin" }) @XmlRootElement(name = "profileEmpty") public class ProfileEmpty { - protected List origin; + protected List origin; - /** - * Gets the value of the origin property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the origin property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getOrigin().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Origin } - * - * - */ - public List getOrigin() { - if (origin == null) { - origin = new ArrayList(); - } - return this.origin; + /** + * Gets the value of the origin property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the origin property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getOrigin().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Origin } + */ + public List getOrigin() { + if (origin == null) { + origin = new ArrayList<>(); } + return this.origin; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java index 80fdf48ae..03f208d6b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java @@ -1,19 +1,18 @@ - package com.avaje.ebeaninternal.server.autotune.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,45 +24,41 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "origin" + "origin" }) @XmlRootElement(name = "profileNew") public class ProfileNew { - protected List origin; + protected List origin; - /** - * Gets the value of the origin property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the origin property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getOrigin().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Origin } - * - * - */ - public List getOrigin() { - if (origin == null) { - origin = new ArrayList(); - } - return this.origin; + /** + * Gets the value of the origin property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the origin property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getOrigin().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Origin } + */ + public List getOrigin() { + if (origin == null) { + origin = new ArrayList<>(); } + return this.origin; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneAllCollection.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneAllCollection.java index 6956f60ab..5f2068842 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneAllCollection.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneAllCollection.java @@ -7,7 +7,7 @@ import java.util.Collection; /** * Event where all tuned query information is collected. *

- * This is for writing the "all" file on shutdown when using runtime tuning. + * This is for writing the "all" file on shutdown when using runtime tuning. *

*/ public class AutoTuneAllCollection { @@ -53,7 +53,7 @@ public class AutoTuneAllCollection { private void loadAllTuned() { Collection all = queryTuner.getAll(); - for (TunedQueryInfo tuned: all) { + for (TunedQueryInfo tuned : all) { document.getOrigin().add(tuned.getOrigin()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneXmlWriter.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneXmlWriter.java index a86f9f7ab..552eb9123 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneXmlWriter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneXmlWriter.java @@ -46,7 +46,7 @@ public class AutoTuneXmlWriter { try { JAXBContext jaxbContext = JAXBContext.newInstance(Autotune.class); Marshaller marshaller = jaxbContext.createMarshaller(); - marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(profiling, file); } catch (JAXBException e) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/BaseQueryTuner.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/BaseQueryTuner.java index 03366ecbf..6d2dcf043 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/BaseQueryTuner.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/BaseQueryTuner.java @@ -30,7 +30,7 @@ public class BaseQueryTuner { /** * Map of the tuned query details per profile query point. */ - private final Map tunedQueryInfoMap = new ConcurrentHashMap(); + private final Map tunedQueryInfoMap = new ConcurrentHashMap<>(); private final SpiEbeanServer server; diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java index 5a7942259..c3ae7f756 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java @@ -63,7 +63,7 @@ public class DefaultAutoTuneService implements AutoTuneService { this.queryTuner = new BaseQueryTuner(config, server, profileManager); this.skipGarbageCollectionOnShutdown = config.isSkipGarbageCollectionOnShutdown(); this.skipProfileReportingOnShutdown = config.isSkipProfileReportingOnShutdown(); - this.defaultGarbageCollectionWait = (long) config.getGarbageCollectionWait(); + this.defaultGarbageCollectionWait = config.getGarbageCollectionWait(); } /** @@ -196,7 +196,7 @@ public class DefaultAutoTuneService implements AutoTuneService { File existingTuning = new File(tuningFile); if (existingTuning.exists()) { // rename the existing autotune.xml file (appending 'now') - if (!existingTuning.renameTo(new File(tuningFile+"."+AutoTuneXmlWriter.now()))) { + if (!existingTuning.renameTo(new File(tuningFile + "." + AutoTuneXmlWriter.now()))) { logger.warn("Failed to rename autotune file [{}]", tuningFile); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileManager.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileManager.java index ff4cca43a..fdf3d702f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileManager.java @@ -31,7 +31,7 @@ public class ProfileManager implements ProfilingListener { /** * Map of the usage and query statistics gathered. */ - private final Map profileMap = new ConcurrentHashMap(); + private final Map profileMap = new ConcurrentHashMap<>(); private final Object monitor = new Object(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOrigin.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOrigin.java index c89a9db87..7f9391abe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOrigin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOrigin.java @@ -26,9 +26,9 @@ public class ProfileOrigin { private final double profilingRate; - private final Map queryStatsMap = new ConcurrentHashMap(); + private final Map queryStatsMap = new ConcurrentHashMap<>(); - private final Map nodeUsageMap = new ConcurrentHashMap(); + private final Map nodeUsageMap = new ConcurrentHashMap<>(); private final Object monitor = new Object(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java index b61372bee..561e1ce46 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java @@ -30,7 +30,7 @@ public class ProfileOriginNodeUsage { private boolean modified; - private final Set aggregateUsed = new LinkedHashSet(); + private final Set aggregateUsed = new LinkedHashSet<>(); public ProfileOriginNodeUsage(String path) { // handle null paths as using ConcurrentHashMap diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginQuery.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginQuery.java index b0a938393..d7f298152 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginQuery.java @@ -30,7 +30,7 @@ public class ProfileOriginQuery implements Serializable { totalMicros.add(micros); } - public AutoTuneCollection.EntryQuery createEntryQuery(boolean reset){ + public AutoTuneCollection.EntryQuery createEntryQuery(boolean reset) { if (reset) { return new AutoTuneCollection.EntryQuery(path, exeCount.sumThenReset(), totalBeanLoaded.sumThenReset(), totalMicros.sumThenReset()); @@ -40,4 +40,4 @@ public class ProfileOriginQuery implements Serializable { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/TunedQueryInfo.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/TunedQueryInfo.java index e6b0bce46..55ab0956c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/TunedQueryInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/TunedQueryInfo.java @@ -13,6 +13,8 @@ import java.io.Serializable; */ public class TunedQueryInfo implements Serializable { + private static final long serialVersionUID = 8661702592481810396L; + private final Origin origin; private final OrmQueryDetail tunedDetail; diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java index 30b1dc833..282c9c8d7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java @@ -15,16 +15,16 @@ import java.util.Set; */ public class CacheChangeSet { - private final List entries = new ArrayList(); + private final List entries = new ArrayList<>(); - private final Set queryCaches = new HashSet(); + private final Set> queryCaches = new HashSet<>(); - private final Map manyChangeMap = new HashMap(); + private final Map manyChangeMap = new HashMap<>(); /** * Set of "base tables" modified used to invalidate entities based on views. */ - private final Set viewInvalidation = new HashSet(); + private final Set viewInvalidation = new HashSet<>(); private final boolean viewEntityInvalidation; @@ -37,11 +37,11 @@ public class CacheChangeSet { /** * Apply the changes to the L2 cache except entity/view invalidation. - * + *

* Return the set of table changes to process invalidation for entities based on views. */ public Set apply() { - for (BeanDescriptor entry : queryCaches) { + for (BeanDescriptor entry : queryCaches) { entry.queryCacheClear(); } for (CacheChange entry : entries) { @@ -137,9 +137,9 @@ public class CacheChangeSet { final ManyKey key; - final List removes = new ArrayList(); + final List removes = new ArrayList<>(); - final Map puts = new LinkedHashMap(); + final Map puts = new LinkedHashMap<>(); boolean clear; @@ -210,7 +210,7 @@ public class CacheChangeSet { @Override public int hashCode() { - return 31 * desc.hashCode() + manyProperty.hashCode(); + return 92821 * desc.hashCode() + manyProperty.hashCode(); } void cacheClear() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java index 4088a9faa..526d56f24 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java @@ -57,14 +57,13 @@ public class CachedBeanData implements Externalizable { } @Override - @SuppressWarnings("unchecked") public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { version = in.readLong(); whenCreated = in.readLong(); if (in.readBoolean()) { discValue = in.readUTF(); } - data = new LinkedHashMap(); + data = new LinkedHashMap<>(); int count = in.readInt(); for (int i = 0; i < count; i++) { String key = in.readUTF(); @@ -83,7 +82,7 @@ public class CachedBeanData implements Externalizable { */ public CachedBeanData update(Map changes, long version) { - Map copy = new HashMap(); + Map copy = new HashMap<>(); copy.putAll(data); copy.putAll(changes); return new CachedBeanData(null, discValue, copy, version); @@ -134,7 +133,7 @@ public class CachedBeanData implements Externalizable { /** * Return all the property data. */ - public Map getData() { + public Map getData() { return data; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java index 387552f37..3f2dc99bb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java @@ -15,7 +15,7 @@ public class CachedBeanDataFromBean { EntityBeanIntercept ebi = bean._ebean_getIntercept(); - Map data = new LinkedHashMap(); + Map data = new LinkedHashMap<>(); BeanProperty idProperty = desc.getIdProperty(); if (idProperty != null) { @@ -27,8 +27,7 @@ public class CachedBeanDataFromBean { BeanProperty[] props = desc.propertiesNonMany(); // extract all the non-many properties - for (int i = 0; i < props.length; i++) { - BeanProperty prop = props[i]; + for (BeanProperty prop : props) { if (ebi.isLoadedProperty(prop.getPropertyIndex())) { data.put(prop.getName(), prop.getCacheDataValue(bean)); } @@ -56,9 +55,9 @@ public class CachedBeanDataFromBean { idProp.setValue(sharableBean, v); } BeanProperty[] propertiesNonTransient = desc.propertiesNonTransient(); - for (int i = 0; i < propertiesNonTransient.length; i++) { - Object v = propertiesNonTransient[i].getValue(bean); - propertiesNonTransient[i].setValue(sharableBean, v); + for (BeanProperty aPropertiesNonTransient : propertiesNonTransient) { + Object v = aPropertiesNonTransient.getValue(bean); + aPropertiesNonTransient.setValue(sharableBean, v); } EntityBeanIntercept intercept = sharableBean._ebean_intercept(); intercept.setReadOnly(true); @@ -67,4 +66,4 @@ public class CachedBeanDataFromBean { } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java index f324409cc..35e9bf52b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java @@ -22,13 +22,13 @@ public class CachedBeanDataToBean { // load the non-many properties BeanProperty[] props = desc.propertiesNonMany(); - for (int i = 0; i < props.length; i++) { - loadProperty(bean, cacheBeanData, ebi, props[i], context); + for (BeanProperty prop : props) { + loadProperty(bean, cacheBeanData, ebi, prop, context); } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - many[i].createReferenceIfNull(bean); + for (BeanPropertyAssocMany aMany : many) { + aMany.createReferenceIfNull(bean); } ebi.setLoadedLazy(); @@ -44,4 +44,4 @@ public class CachedBeanDataToBean { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedManyIds.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedManyIds.java index b84c91194..dcc5b2f96 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedManyIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedManyIds.java @@ -38,7 +38,7 @@ public class CachedManyIds implements Externalizable { @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int size = in.readInt(); - idList = new ArrayList(size); + idList = new ArrayList<>(size); for (int i = 0; i < size; i++) { idList.add(in.readObject()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java index 5834986d2..cae96c6a5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java @@ -1,7 +1,7 @@ package com.avaje.ebeaninternal.server.cache; -import com.avaje.ebean.annotation.CacheQueryTuning; import com.avaje.ebean.annotation.CacheBeanTuning; +import com.avaje.ebean.annotation.CacheQueryTuning; import com.avaje.ebean.cache.ServerCache; import com.avaje.ebean.cache.ServerCacheFactory; import com.avaje.ebean.cache.ServerCacheOptions; @@ -15,9 +15,9 @@ import java.util.concurrent.ConcurrentHashMap; */ public class DefaultCacheHolder { - private final ConcurrentHashMap concMap = new ConcurrentHashMap(); + private final ConcurrentHashMap concMap = new ConcurrentHashMap<>(); - private final HashMap synchMap = new HashMap(); + private final HashMap synchMap = new HashMap<>(); private final Object monitor = new Object(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java index 8a5dc8a32..0204c677e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java @@ -4,7 +4,6 @@ import com.avaje.ebean.BackgroundExecutor; import com.avaje.ebean.cache.ServerCache; import com.avaje.ebean.cache.ServerCacheOptions; import com.avaje.ebean.cache.ServerCacheStatistics; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,7 +67,7 @@ public class DefaultServerCache implements ServerCache { * Construct using a ConcurrentHashMap and cache options. */ public DefaultServerCache(String name, ServerCacheOptions options) { - this(name, new ConcurrentHashMap(), options); + this(name, new ConcurrentHashMap<>(), options); } /** @@ -277,7 +276,7 @@ public class DefaultServerCache implements ServerCache { long trimmedByTTL = 0; long trimmedByLRU = 0; - ArrayList activeList = new ArrayList(); + ArrayList activeList = new ArrayList<>(); long idleExpire = System.currentTimeMillis() - (maxIdleSecs * 1000); long ttlExpire = System.currentTimeMillis() - (maxSecsToLive * 1000); @@ -323,7 +322,7 @@ public class DefaultServerCache implements ServerCache { if (logger.isTraceEnabled()) { logger.trace("Executed trim of cache {} in [{}]millis idle[{}] timeToLive[{}] accessTime[{}]" - , name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU); + , name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java index 1e00c9564..3d6c0bb31 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java @@ -4,8 +4,8 @@ import com.avaje.ebean.event.changelog.BeanChange; import com.avaje.ebean.event.changelog.ChangeLogListener; import com.avaje.ebean.event.changelog.ChangeSet; import com.avaje.ebean.event.changelog.ChangeType; -import com.avaje.ebean.plugin.SpiServer; import com.avaje.ebean.plugin.Plugin; +import com.avaje.ebean.plugin.SpiServer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegister.java b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegister.java index f26cf8543..d0c0b68ea 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegister.java @@ -7,6 +7,7 @@ import com.avaje.ebean.event.changelog.ChangeLogFilter; import com.avaje.ebean.event.changelog.ChangeLogRegister; import com.avaje.ebeaninternal.server.deploy.parse.AnnotationBase; +import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -41,10 +42,8 @@ public class DefaultChangeLogRegister implements ChangeLogRegister { return insertModeInclude(changeLog.inserts()) ? INCLUDE_INSERTS : EXCLUDE_INSERTS; } - Set updateProps = new HashSet(); - for (int i = 0; i < updatesThatInclude.length; i++) { - updateProps.add(updatesThatInclude[i]); - } + Set updateProps = new HashSet<>(); + Collections.addAll(updateProps, updatesThatInclude); return new UpdateFilter(insertModeInclude(changeLog.inserts()), updateProps); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/cluster/BinaryMessageList.java b/src/main/java/com/avaje/ebeaninternal/server/cluster/BinaryMessageList.java index 17d7e6b33..d46111512 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cluster/BinaryMessageList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cluster/BinaryMessageList.java @@ -10,7 +10,7 @@ import java.util.List; */ public class BinaryMessageList { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); public void add(BinaryMessage msg) { list.add(msg); diff --git a/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java b/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java index 30af29e53..90f848946 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java @@ -19,7 +19,7 @@ public class ClusterManager { private static final Logger logger = LoggerFactory.getLogger(ClusterManager.class); - private final ConcurrentHashMap serverMap = new ConcurrentHashMap(); + private final ConcurrentHashMap serverMap = new ConcurrentHashMap<>(); private final Object monitor = new Object(); @@ -49,7 +49,7 @@ public class ClusterManager { } if (factory == null) { throw new IllegalStateException("No ClusterTransportFactory found in classpath. " - + " Probably need to add the avaje-ebeanorm-cluster dependency"); + + " Probably need to add the avaje-ebeanorm-cluster dependency"); } return factory; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/BasicTypeConverter.java b/src/main/java/com/avaje/ebeaninternal/server/core/BasicTypeConverter.java index d98ad3f65..fa83a4764 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/BasicTypeConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/BasicTypeConverter.java @@ -151,7 +151,7 @@ public final class BasicTypeConverter implements Serializable { return (Boolean) value; } if (value instanceof Number) { - return ((Number)value).intValue() == 1; + return ((Number) value).intValue() == 1; } String s = value.toString(); return s.equalsIgnoreCase(dbTrueValue); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/CObjectGraphNodeStatistics.java b/src/main/java/com/avaje/ebeaninternal/server/core/CObjectGraphNodeStatistics.java index 96fe96d6a..41349515d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/CObjectGraphNodeStatistics.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/CObjectGraphNodeStatistics.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.core; +import com.avaje.ebean.bean.ObjectGraphNode; +import com.avaje.ebean.meta.MetaObjectGraphNodeStats; + import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.LongAdder; -import com.avaje.ebean.meta.*; -import com.avaje.ebean.bean.ObjectGraphNode; - /** * Helper to collect the query execution statistics for a given node. */ @@ -34,7 +34,7 @@ public class CObjectGraphNodeStatistics { public MetaObjectGraphNodeStats get(boolean reset) { if (reset) { return new Snapshot(node, startTime.getAndSet(System.currentTimeMillis()), count.sumThenReset(), - totalTime.sumThenReset(), totalBeans.sumThenReset()); + totalTime.sumThenReset(), totalBeans.sumThenReset()); } else { return new Snapshot(node, startTime.get(), count.sum(), totalTime.sum(), totalBeans.sum()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/ClassPathScanners.java b/src/main/java/com/avaje/ebeaninternal/server/core/ClassPathScanners.java index 6464fe709..e08b28eef 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/ClassPathScanners.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/ClassPathScanners.java @@ -18,7 +18,7 @@ public class ClassPathScanners { */ public static List find(ServerConfig serverConfig) { - List scanners = new ArrayList(); + List scanners = new ArrayList<>(); ServiceLoader scannerLoader = serverConfig.serviceLoad(ClassPathScannerFactory.class); for (ClassPathScannerFactory factory : scannerLoader) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DatabasePlatformFactory.java b/src/main/java/com/avaje/ebeaninternal/server/core/DatabasePlatformFactory.java index 49c5cac20..d882208b1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DatabasePlatformFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DatabasePlatformFactory.java @@ -1,18 +1,28 @@ package com.avaje.ebeaninternal.server.core; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; - -import javax.persistence.PersistenceException; -import javax.sql.DataSource; - import com.avaje.ebean.config.ServerConfig; -import com.avaje.ebean.config.dbplatform.*; +import com.avaje.ebean.config.dbplatform.DB2Platform; +import com.avaje.ebean.config.dbplatform.DatabasePlatform; +import com.avaje.ebean.config.dbplatform.H2Platform; +import com.avaje.ebean.config.dbplatform.HsqldbPlatform; +import com.avaje.ebean.config.dbplatform.MsSqlServer2000Platform; +import com.avaje.ebean.config.dbplatform.MsSqlServer2005Platform; +import com.avaje.ebean.config.dbplatform.MySqlPlatform; +import com.avaje.ebean.config.dbplatform.OraclePlatform; +import com.avaje.ebean.config.dbplatform.Postgres8Platform; +import com.avaje.ebean.config.dbplatform.PostgresPlatform; +import com.avaje.ebean.config.dbplatform.SQLitePlatform; +import com.avaje.ebean.config.dbplatform.SqlAnywherePlatform; import com.avaje.ebean.dbmigration.DbOffline; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; + /** * Create a DatabasePlatform from the configuration. *

@@ -135,37 +145,29 @@ public class DatabasePlatformFactory { if (dbProductName.contains("oracle")) { return new OraclePlatform(); - } - else if (dbProductName.contains("microsoft")) { + } else if (dbProductName.contains("microsoft")) { if (majorVersion > 8) { return new MsSqlServer2005Platform(); } else { return new MsSqlServer2000Platform(); } - } - else if (dbProductName.contains("mysql")) { + } else if (dbProductName.contains("mysql")) { return new MySqlPlatform(); - } - else if (dbProductName.contains("h2")) { + } else if (dbProductName.contains("h2")) { return new H2Platform(); - } - else if (dbProductName.contains("hsql database engine")) { + } else if (dbProductName.contains("hsql database engine")) { return new HsqldbPlatform(); - } - else if (dbProductName.contains("postgres")) { + } else if (dbProductName.contains("postgres")) { return new PostgresPlatform(); - } - else if (dbProductName.contains("sqlite")) { + } else if (dbProductName.contains("sqlite")) { return new SQLitePlatform(); - } - else if (dbProductName.contains("db2")) { + } else if (dbProductName.contains("db2")) { return new DB2Platform(); - } - else if (dbProductName.contains("sql anywhere")) { + } else if (dbProductName.contains("sql anywhere")) { return new SqlAnywherePlatform(); } - // use the standard one + // use the standard one return new DatabasePlatform(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutor.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutor.java index e71bc42ef..f32a3d512 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutor.java @@ -11,32 +11,32 @@ import java.util.concurrent.TimeUnit; */ public class DefaultBackgroundExecutor implements SpiBackgroundExecutor { - private final DaemonScheduleThreadPool schedulePool; + private final DaemonScheduleThreadPool schedulePool; private final DaemonExecutorService pool; /** * Construct the default implementation of BackgroundExecutor. */ - public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix) { - this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix); - this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix+"-periodic-"); - } + public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix) { + this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix); + this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix + "-periodic-"); + } - /** - * Execute a Runnable using a background thread. - */ - public void execute(Runnable r) { - pool.execute(r); - } + /** + * Execute a Runnable using a background thread. + */ + public void execute(Runnable r) { + pool.execute(r); + } - public void executePeriodically(Runnable r, long delay, TimeUnit unit) { - schedulePool.scheduleWithFixedDelay(r, delay, delay, unit); - } + public void executePeriodically(Runnable r, long delay, TimeUnit unit) { + schedulePool.scheduleWithFixedDelay(r, delay, delay, unit); + } + + public void shutdown() { + pool.shutdown(); + schedulePool.shutdown(); + } - public void shutdown() { - pool.shutdown(); - schedulePool.shutdown(); - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBeanLoader.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBeanLoader.java index 50ad811d5..fb904faeb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBeanLoader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBeanLoader.java @@ -140,7 +140,7 @@ public class DefaultBeanLoader { } } - SpiQuery query = (SpiQuery) server.createQuery(parentDesc.getBeanType()); + SpiQuery query = server.createQuery(parentDesc.getBeanType()); if (refresh) { // populate a new collection @@ -205,7 +205,7 @@ public class DefaultBeanLoader { return; } - SpiQuery query = (SpiQuery) server.createQuery(loadRequest.getBeanType()); + SpiQuery query = server.createQuery(loadRequest.getBeanType()); loadRequest.configureQuery(query, idList); List list = executeQuery(loadRequest, query); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallStackFactory.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallStackFactory.java index 869be6a1f..7a14ceae0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallStackFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallStackFactory.java @@ -19,7 +19,7 @@ public class DefaultCallStackFactory implements CallStackFactory { int hc = 0; for (int i = 1; i < callStack.length; i++) { - hc = 31 * hc + callStack[i].hashCode(); + hc = 92821 * hc + callStack[i].hashCode(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallableSql.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallableSql.java index 85090eb8e..f74b340b6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallableSql.java @@ -1,9 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.io.Serializable; -import java.sql.CallableStatement; -import java.sql.SQLException; - import com.avaje.ebean.CallableSql; import com.avaje.ebean.EbeanServer; import com.avaje.ebeaninternal.api.BindParams; @@ -11,6 +7,10 @@ import com.avaje.ebeaninternal.api.BindParams.Param; import com.avaje.ebeaninternal.api.SpiCallableSql; import com.avaje.ebeaninternal.api.TransactionEventTable; +import java.io.Serializable; +import java.sql.CallableStatement; +import java.sql.SQLException; + public class DefaultCallableSql implements Serializable, SpiCallableSql { diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java index 009513583..87f4a610e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java @@ -14,8 +14,8 @@ import com.avaje.ebean.config.dbplatform.DatabasePlatform; import com.avaje.ebean.dbmigration.DbOffline; import com.avaje.ebeaninternal.api.SpiBackgroundExecutor; import com.avaje.ebeaninternal.api.SpiEbeanServer; -import com.avaje.ebeaninternal.server.cache.DefaultServerCachePlugin; import com.avaje.ebeaninternal.server.cache.DefaultServerCacheManager; +import com.avaje.ebeaninternal.server.cache.DefaultServerCachePlugin; import com.avaje.ebeaninternal.server.cluster.ClusterManager; import com.avaje.ebeaninternal.server.core.bootup.BootupClassPathSearch; import com.avaje.ebeaninternal.server.core.bootup.BootupClasses; @@ -238,9 +238,9 @@ public class DefaultContainer implements SpiContainer { if (dbPlatform == null) { DatabasePlatformFactory factory = new DatabasePlatformFactory(); DatabasePlatform db = factory.create(config); - db.configure(config); + db.configure(config.getDbTypeConfig()); config.setDatabasePlatform(db); - logger.info("DatabasePlatform name:" + config.getName() + " platform:" + db.getName()); + logger.info("DatabasePlatform name:{} platform:{}", config.getName(), db.getName()); } } @@ -286,7 +286,7 @@ public class DefaultContainer implements SpiContainer { DataSourceFactory factory = config.service(DataSourceFactory.class); if (factory == null) { throw new IllegalStateException("No DataSourceFactory service implementation found in class path." - + " Probably missing dependency to avaje-datasource?"); + + " Probably missing dependency to avaje-datasource?"); } DataSourceAlertFactory alertFactory = config.service(DataSourceAlertFactory.class); @@ -306,7 +306,7 @@ public class DefaultContainer implements SpiContainer { if (dsConfig.getListener() == null) { String poolListener = dsConfig.getPoolListener(); if (poolListener != null) { - dsConfig.setListener((DataSourcePoolListener)config.getClassLoadConfig().newInstance(poolListener)); + dsConfig.setListener((DataSourcePoolListener) config.getClassLoadConfig().newInstance(poolListener)); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java index d0fd38992..b0f7e9bf0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java @@ -1,24 +1,24 @@ package com.avaje.ebeaninternal.server.core; +import com.avaje.ebean.meta.MetaBeanInfo; +import com.avaje.ebean.meta.MetaInfoManager; +import com.avaje.ebean.meta.MetaObjectGraphNodeStats; +import com.avaje.ebean.meta.MetaQueryPlanStatistic; + import java.util.ArrayList; import java.util.List; -import com.avaje.ebean.meta.MetaBeanInfo; -import com.avaje.ebean.meta.MetaQueryPlanStatistic; -import com.avaje.ebean.meta.MetaInfoManager; -import com.avaje.ebean.meta.MetaObjectGraphNodeStats; - /** * DefaultServer based implementation of MetaInfoManager. */ public class DefaultMetaInfoManager implements MetaInfoManager { private final DefaultServer server; - + public DefaultMetaInfoManager(DefaultServer server) { this.server = server; } - + @Override public MetaBeanInfo getMetaBeanInfo(Class beanClass) { return server.getBeanDescriptor(beanClass); @@ -27,24 +27,22 @@ public class DefaultMetaInfoManager implements MetaInfoManager { @Override public List getMetaBeanInfoList() { - return new ArrayList(server.getBeanDescriptors()); + return new ArrayList<>(server.getBeanDescriptors()); } @Override public List collectQueryPlanStatistics(boolean reset) { - - List list = new ArrayList(); - + + List list = new ArrayList<>(); for (MetaBeanInfo metaBeanInfo : getMetaBeanInfoList()) { list.addAll(metaBeanInfo.collectQueryPlanStatistics(reset)); } - - return list; + return list; } - + public List collectNodeStatistics(boolean reset) { - List list = new ArrayList(); + List list = new ArrayList<>(); for (CObjectGraphNodeStatistics nodeStatistics : server.objectGraphStats.values()) { MetaObjectGraphNodeStats nodeStats = nodeStatistics.get(reset); @@ -55,5 +53,5 @@ public class DefaultMetaInfoManager implements MetaInfoManager { } return list; } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index 99aab043f..5b82a9fcd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -1,6 +1,36 @@ package com.avaje.ebeaninternal.server.core; -import com.avaje.ebean.*; +import com.avaje.ebean.AutoTune; +import com.avaje.ebean.BackgroundExecutor; +import com.avaje.ebean.BeanState; +import com.avaje.ebean.CallableSql; +import com.avaje.ebean.DocumentStore; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.Filter; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.PagedList; +import com.avaje.ebean.PersistenceContextScope; +import com.avaje.ebean.Query; +import com.avaje.ebean.QueryEachConsumer; +import com.avaje.ebean.QueryEachWhileConsumer; +import com.avaje.ebean.QueryIterator; +import com.avaje.ebean.RawSql; +import com.avaje.ebean.SqlQuery; +import com.avaje.ebean.SqlRow; +import com.avaje.ebean.SqlUpdate; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.TransactionCallback; +import com.avaje.ebean.TxCallable; +import com.avaje.ebean.TxIsolation; +import com.avaje.ebean.TxRunnable; +import com.avaje.ebean.TxScope; +import com.avaje.ebean.TxType; +import com.avaje.ebean.Update; +import com.avaje.ebean.UpdateQuery; +import com.avaje.ebean.ValuePair; +import com.avaje.ebean.Version; import com.avaje.ebean.bean.BeanCollection; import com.avaje.ebean.bean.CallStack; import com.avaje.ebean.bean.EntityBean; @@ -87,13 +117,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private static final Logger logger = LoggerFactory.getLogger(DefaultServer.class); private static final int IGNORE_LEADING_ELEMENTS = 5; - + private static final String COM_AVAJE_EBEAN = "com.avaje.ebean"; private static final String ORG_AVAJE_EBEAN = "org.avaje.ebean"; private final ServerConfig serverConfig; - + private final String serverName; private final DatabasePlatform databasePlatform; @@ -113,7 +143,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * false; */ private final boolean rollbackOnChecked; - + /** * Handles the save, delete, updateSql CallableSql. */ @@ -152,7 +182,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private final DocumentStore documentStore; private final MetaInfoManager metaInfoManager; - + /** * The default PersistenceContextScope used if it is not explicitly set on a query. */ @@ -162,21 +192,21 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * Flag set when the server has shutdown. */ private boolean shutdown; - + /** * The default batch size for lazy loading beans or collections. */ private final int lazyLoadBatchSize; - /** - * The query batch size + /** + * The query batch size */ private final int queryBatchSize; private final boolean updateAllPropertiesInBatch; private final boolean collectQueryOrigins; - + private final boolean collectQueryStatsByNode; /** @@ -190,7 +220,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { public DefaultServer(InternalConfiguration config, ServerCacheManager cache) { this.serverConfig = config.getServerConfig(); - this.objectGraphStats = new ConcurrentHashMap(); + this.objectGraphStats = new ConcurrentHashMap<>(); this.metaInfoManager = new DefaultMetaInfoManager(this); this.serverCacheManager = cache; this.databasePlatform = config.getDatabasePlatform(); @@ -235,7 +265,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { this.ddlGenerator = new DdlGenerator(this, serverConfig); configureServerPlugins(); - + // Register with the JVM Shutdown hook ShutdownManager.registerEbeanServer(this); } @@ -274,6 +304,10 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { return lazyLoadBatchSize; } + public int getQueryBatchSize() { + return queryBatchSize; + } + public ServerConfig getServerConfig() { return serverConfig; } @@ -534,7 +568,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * then it will returned that object. *

*/ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public T getReference(Class type, Object id) { if (id == null) { @@ -550,13 +584,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { pc = t.getPersistenceContext(); Object existing = desc.contextGet(pc, id); if (existing != null) { - return (T)existing; + return (T) existing; } } InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo == null) { - return (T)desc.contextRef(pc, null, false, id); + return (T) desc.contextRef(pc, null, false, id); } BeanProperty idProp = desc.getIdProperty(); @@ -648,32 +682,32 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { TxType type = scope.getType(); switch (type) { - case REQUIRED: - return t == null; + case REQUIRED: + return t == null; - case REQUIRES_NEW: - return true; + case REQUIRES_NEW: + return true; - case MANDATORY: - if (t == null) { - throw new PersistenceException("Transaction missing when MANDATORY"); - } - return true; + case MANDATORY: + if (t == null) { + throw new PersistenceException("Transaction missing when MANDATORY"); + } + return true; - case NEVER: - if (t != null) { - throw new PersistenceException("Transaction exists for Transactional NEVER"); - } - return false; + case NEVER: + if (t != null) { + throw new PersistenceException("Transaction exists for Transactional NEVER"); + } + return false; - case SUPPORTS: - return false; + case SUPPORTS: + return false; - case NOT_SUPPORTED: - throw new RuntimeException("NOT_SUPPORTED should already be handled?"); + case NOT_SUPPORTED: + throw new RuntimeException("NOT_SUPPORTED should already be handled?"); - default: - throw new RuntimeException("Should never get here?"); + default: + throw new RuntimeException("Should never get here?"); } } @@ -794,23 +828,23 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { *

*

* Code example:
- * + *

*

    * <code>
    * Ebean.startTransaction();
    * try {
    * 	// do some fetching and or persisting
-   * 
+   *
    * 	// commit at the end
    * 	Ebean.commitTransaction();
-   * 
+   *
    * } finally {
    * 	// if commit didn't occur then rollback the transaction
    * 	Ebean.endTransaction();
    * }
    * </code>
    * 
- * + *

*

*/ public void endTransaction() { @@ -858,7 +892,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { if (beanDescriptor == null) { throw new PersistenceException("BeanDescriptor not found, is [" + query.getBeanType() + "] an entity bean?"); } - return ((SpiQuery)query).validate(beanDescriptor); + return ((SpiQuery) query).validate(beanDescriptor); } public Filter filter(Class beanType) { @@ -867,7 +901,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { String m = beanType.getName() + " is NOT an Entity Bean registered with this server?"; throw new PersistenceException(m); } - return new ElFilter(desc); + return new ElFilter<>(desc); } public CsvReader createCsvReader(Class beanType) { @@ -875,11 +909,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { if (descriptor == null) { throw new NullPointerException("BeanDescriptor for " + beanType.getName() + " not found"); } - return new TCsvReader(this, descriptor); + return new TCsvReader<>(this, descriptor); } public UpdateQuery update(Class beanType) { - return new DefaultUpdateQuery(createQuery(beanType)); + return new DefaultUpdateQuery<>(createQuery(beanType)); } public Query find(Class beanType) { @@ -917,7 +951,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { if (desc == null) { throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?"); } - return new DefaultOrmQuery(desc, this, expressionFactory); + return new DefaultOrmQuery<>(desc, this, expressionFactory); } public Update createUpdate(Class beanType, String ormUpdate) { @@ -927,7 +961,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { throw new PersistenceException(m); } - return new DefaultOrmUpdate(beanType, this, desc.getBaseTable(), ormUpdate); + return new DefaultOrmUpdate<>(beanType, this, desc.getBaseTable(), ormUpdate); } public SqlQuery createSqlQuery(String sql) { @@ -985,7 +1019,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { query.setOrigin(createCallStack()); } - OrmQueryRequest request = new OrmQueryRequest(this, queryEngine, query, (SpiTransaction) t); + OrmQueryRequest request = new OrmQueryRequest<>(this, queryEngine, query, (SpiTransaction) t); request.prepareQuery(); return request; @@ -1052,7 +1086,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { if (SpiQuery.Mode.NORMAL.equals(spiQuery.getMode()) && !spiQuery.isLoadBeanCache()) { // See if we can skip doing the fetch completely by getting the bean from the // persistence context or the bean cache - T bean = findIdCheckPersistenceContextAndCache(t, spiQuery, spiQuery.getId()); + T bean = findIdCheckPersistenceContextAndCache(t, spiQuery, spiQuery.getId()); if (bean != null) { return bean; } @@ -1112,7 +1146,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public Set findSet(Query query, Transaction t) { SpiOrmQueryRequest request = createQueryRequest(Type.SET, query, t); @@ -1124,14 +1158,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); - return (Set) request.findSet(); + return request.findSet(); } finally { request.endTransIfRequired(); } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public Map findMap(Query query, Transaction t) { SpiOrmQueryRequest request = createQueryRequest(Type.MAP, query, t); @@ -1143,7 +1177,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); - return (Map) request.findMap(); + return request.findMap(); } finally { request.endTransIfRequired(); @@ -1152,9 +1186,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { @Override @SuppressWarnings("unchecked") - public List findSingleAttributeList(Query query, Transaction t) { + public List findSingleAttributeList(Query query, Transaction t) { - SpiOrmQueryRequest request = createQueryRequest(Type.ATTRIBUTE, query, t); + SpiOrmQueryRequest request = createQueryRequest(Type.ATTRIBUTE, query, t); Object result = request.getFromQueryCache(); if (result != null) { return (List) result; @@ -1190,18 +1224,18 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } - public List findIds(Query query, Transaction t) { + public List findIds(Query query, Transaction t) { - return findIdsWithCopy(((SpiQuery) query).copy(), t); + return findIdsWithCopy(((SpiQuery) query).copy(), t); } - public List findIdsWithCopy(Query query, Transaction t) { + public List findIdsWithCopy(Query query, Transaction t) { SpiOrmQueryRequest request = createQueryRequest(Type.ID_LIST, query, t); try { request.initTransIfRequired(); return request.findIds(); - + } finally { request.endTransIfRequired(); } @@ -1238,9 +1272,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { Transaction newTxn = createTransaction(); - CallableQueryRowCount call = new CallableQueryRowCount(this, copy, newTxn); + CallableQueryRowCount call = new CallableQueryRowCount<>(this, copy, newTxn); - QueryFutureRowCount queryFuture = new QueryFutureRowCount(call); + QueryFutureRowCount queryFuture = new QueryFutureRowCount<>(call); backgroundExecutor.execute(queryFuture.getFutureTask()); return queryFuture; @@ -1257,8 +1291,8 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { Transaction newTxn = createTransaction(); - CallableQueryIds call = new CallableQueryIds(this, copy, newTxn); - QueryFutureIds queryFuture = new QueryFutureIds(call); + CallableQueryIds call = new CallableQueryIds<>(this, copy, newTxn); + QueryFutureIds queryFuture = new QueryFutureIds<>(call); backgroundExecutor.execute(queryFuture.getFutureTask()); @@ -1280,8 +1314,8 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // Create a new transaction solely to execute the findList() at some future time Transaction newTxn = createTransaction(); - CallableQueryList call = new CallableQueryList(this, spiQuery, newTxn); - QueryFutureList queryFuture = new QueryFutureList(call); + CallableQueryList call = new CallableQueryList<>(this, spiQuery, newTxn); + QueryFutureList queryFuture = new QueryFutureList<>(call); backgroundExecutor.execute(queryFuture.getFutureTask()); return queryFuture; } @@ -1289,7 +1323,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { @Override public PagedList findPagedList(Query query, Transaction transaction) { - SpiQuery spiQuery = (SpiQuery)query; + SpiQuery spiQuery = (SpiQuery) query; int maxRows = spiQuery.getMaxRows(); if (maxRows == 0) { throw new PersistenceException("maxRows must be specified for findPagedList() query"); @@ -1299,7 +1333,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { return docStore().findPagedList(createQueryRequest(Type.LIST, query, transaction)); } - return new LimitOffsetPagedList(this, spiQuery); + return new LimitOffsetPagedList<>(this, spiQuery); } public QueryIterator findIterate(Query query, Transaction t) { @@ -1370,7 +1404,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); return request.findList(); - + } finally { request.endTransIfRequired(); } @@ -1441,18 +1475,18 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { throw new IllegalArgumentException("This bean is not an EntityBean?"); } // mark the bean as dirty (so that an update will not get skipped) - ((EntityBean)bean)._ebean_getIntercept().setDirty(true); + ((EntityBean) bean)._ebean_getIntercept().setDirty(true); } /** - * Update the bean using the default 'updatesDeleteMissingChildren' setting. + * Update the bean using the default 'updatesDeleteMissingChildren' setting. */ public void update(Object bean) { update(bean, null); } /** - * Update the bean using the default 'updatesDeleteMissingChildren' setting. + * Update the bean using the default 'updatesDeleteMissingChildren' setting. */ public void update(Object bean, Transaction t) { persister.update(checkEntityBean(bean), t); @@ -1479,7 +1513,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // Nothing to update? return; } - + TransWrapper wrap = initTransIfRequired(t); try { SpiTransaction trans = wrap.transaction; @@ -1487,13 +1521,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { update(checkEntityBean(bean), trans); } wrap.commitIfCreated(); - + } catch (RuntimeException e) { wrap.rollbackIfCreated(); throw e; } } - + /** * Insert the bean. */ @@ -1524,7 +1558,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // Nothing to insert? return; } - + TransWrapper wrap = initTransIfRequired(t); try { SpiTransaction trans = wrap.transaction; @@ -1532,7 +1566,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { persister.insert(checkEntityBean(bean), trans); } wrap.commitIfCreated(); - + } catch (RuntimeException e) { wrap.rollbackIfCreated(); throw e; @@ -1613,11 +1647,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { throw new IllegalArgumentException(Message.msg("bean.isnull")); } if (!(bean instanceof EntityBean)) { - throw new IllegalArgumentException("Was expecting an EntityBean but got a "+bean.getClass()); + throw new IllegalArgumentException("Was expecting an EntityBean but got a " + bean.getClass()); } - return (EntityBean)bean; + return (EntityBean) bean; } - + @Override public int saveAll(Collection beans, Transaction transaction) throws OptimisticLockException { return saveAllInternal(beans.iterator(), transaction); @@ -1849,15 +1883,15 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { public void register(BeanPersistController c) { List> list = beanDescriptorManager.getBeanDescriptorList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).register(c); + for (BeanDescriptor aList : list) { + aList.register(c); } } public void deregister(BeanPersistController c) { List> list = beanDescriptorManager.getBeanDescriptorList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).deregister(c); + for (BeanDescriptor aList : list) { + aList.deregister(c); } } @@ -2037,14 +2071,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // immutable thread safe so return shared instance return jsonContext; } - + @Override public void collectQueryStats(ObjectGraphNode node, long loadedBeanCount, long timeMicros) { - + if (collectQueryStatsByNode) { CObjectGraphNodeStatistics nodeStatistics = objectGraphStats.get(node); if (nodeStatistics == null) { - // race condition here but I actually don't care too much if we miss a + // race condition here but I actually don't care too much if we miss a // few early statistics - especially when the server is warming up etc nodeStatistics = new CObjectGraphNodeStatistics(node); objectGraphStats.put(node, nodeStatistics); @@ -2052,5 +2086,5 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { nodeStatistics.add(loadedBeanCount, timeMicros); } } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultSqlUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultSqlUpdate.java index 98357e1bc..66c025526 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultSqlUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultSqlUpdate.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.io.Serializable; - import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.SqlUpdate; @@ -9,6 +7,8 @@ import com.avaje.ebean.Update; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.SpiSqlUpdate; +import java.io.Serializable; + /** * A SQL Update Delete or Insert statement that can be executed. For the times * when you want to use Sql DML rather than a ORM bean approach. Refer to the @@ -21,159 +21,104 @@ import com.avaje.ebeaninternal.api.SpiSqlUpdate; * SqlUpdate is designed for general DML sql and CallableSql is * designed for use with stored procedures. *

- * - *
- * // String sql = "update f_topic set post_count = :count where id = :topicId";
- * 
- * SqlUpdate update = new SqlUpdate(sql);
- * update.setParameter("count", 1);
- * update.setParameter("topicId", 50);
- * 
- * int modifiedCount = Ebean.execute(update);
- * 
- * - *

- * Note that when the SqlUpdate is executed via Ebean.execute() the sql is - * parsed to determine if it is an update, delete or insert. In addition the - * table modified is deduced. If isAutoTableMod() is true, then this - * is then added to the TransactionEvent and cache invalidation etc is - * maintained. This means you don't need to use the Ebean.externalModification() - * method as this has already been done. - *

- *

- * You can sql.setAutoTableMod(false); to stop the automatic table modification - *

- *

- * EXAMPLE: Using JDBC batching with SqlUpdate - *

- *
- * 
- * String data = "This is a simple test of the batch processing"
- * 		+ " mode and the transaction execute batch method";
- * 
- * String[] da = data.split(" ");
- * 
- * String sql = "insert into junk (word) values (?)";
- * 
- * SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
- * 
- * Transaction t = Ebean.beginTransaction();
- * t.setBatchMode(true);
- * t.setBatchSize(3);
- * try {
- * 	for (int i = 0; i < da.length; i++) {
- * 
- * 		sqlUpdate.setParameter(1, da[i]);
- * 		sqlUpdate.execute();
- * 	}
- * 
- * 	// NB: commit implicitly flushes the batch 
- * 	Ebean.commitTransaction();
- * 
- * } finally {
- * 	Ebean.endTransaction();
- * }
- * 
- * @see com.avaje.ebean.CallableSql - * @see com.avaje.ebean.Ebean#execute(SqlUpdate) */ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate { - private static final long serialVersionUID = -6493829438421253102L; + private static final long serialVersionUID = -6493829438421253102L; - private transient final EbeanServer server; + private transient final EbeanServer server; - /** - * The parameters used to bind to the sql. - */ - private final BindParams bindParams; + /** + * The parameters used to bind to the sql. + */ + private final BindParams bindParams; - /** - * The sql update or delete statement. - */ - private final String sql; + /** + * The sql update or delete statement. + */ + private final String sql; /** * The actual sql with named parameters converted. */ private String generatedSql; - /** - * Some descriptive text that can be put into the transaction log. - */ - private String label = ""; + /** + * Some descriptive text that can be put into the transaction log. + */ + private String label = ""; - /** - * The statement execution timeout. - */ - private int timeout; + /** + * The statement execution timeout. + */ + private int timeout; - /** - * Automatically detect the table being modified by this sql. This will - * register this information so that eBean invalidates cached objects if - * required. - */ - private boolean isAutoTableMod = true; + /** + * Automatically detect the table being modified by this sql. This will + * register this information so that eBean invalidates cached objects if + * required. + */ + private boolean isAutoTableMod = true; - /** - * Helper to add positioned parameters in order. - */ - private int addPos; + /** + * Helper to add positioned parameters in order. + */ + private int addPos; - /** - * Create with server sql and bindParams object. - *

- * Useful if you are building the sql and binding parameters at the - * same time. - *

- */ - public DefaultSqlUpdate(EbeanServer server, String sql, BindParams bindParams) { - this.server = server; - this.sql = sql; - this.bindParams = bindParams; - } - - /** - * Create with a specific server. This means you can use the - * SqlUpdate.execute() method. - */ - public DefaultSqlUpdate(EbeanServer server, String sql) { - this(server, sql, new BindParams()); - } + /** + * Create with server sql and bindParams object. + *

+ * Useful if you are building the sql and binding parameters at the + * same time. + *

+ */ + public DefaultSqlUpdate(EbeanServer server, String sql, BindParams bindParams) { + this.server = server; + this.sql = sql; + this.bindParams = bindParams; + } - /** - * Create with some sql. - */ - public DefaultSqlUpdate(String sql) { - this(null, sql, new BindParams()); - } + /** + * Create with a specific server. This means you can use the + * SqlUpdate.execute() method. + */ + public DefaultSqlUpdate(EbeanServer server, String sql) { + this(server, sql, new BindParams()); + } - public int execute() { - if (server != null) { - return server.execute(this); - } else { - // Hopefully this doesn't catch anyone out... - return Ebean.execute(this); - } - } + /** + * Create with some sql. + */ + public DefaultSqlUpdate(String sql) { + this(null, sql, new BindParams()); + } - public boolean isAutoTableMod() { - return isAutoTableMod; - } + public int execute() { + if (server != null) { + return server.execute(this); + } else { + // Hopefully this doesn't catch anyone out... + return Ebean.execute(this); + } + } - public SqlUpdate setAutoTableMod(boolean isAutoTableMod) { - this.isAutoTableMod = isAutoTableMod; - return this; - } + public boolean isAutoTableMod() { + return isAutoTableMod; + } - public String getLabel() { - return label; - } + public SqlUpdate setAutoTableMod(boolean isAutoTableMod) { + this.isAutoTableMod = isAutoTableMod; + return this; + } - public SqlUpdate setLabel(String label) { - this.label = label; - return this; - } + public String getLabel() { + return label; + } + + public SqlUpdate setLabel(String label) { + this.label = label; + return this; + } public String getGeneratedSql() { return generatedSql; @@ -185,57 +130,57 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate { } public String getSql() { - return sql; - } + return sql; + } - public int getTimeout() { - return timeout; - } + public int getTimeout() { + return timeout; + } - public SqlUpdate setTimeout(int secs) { - this.timeout = secs; - return this; - } + public SqlUpdate setTimeout(int secs) { + this.timeout = secs; + return this; + } public void addParameter(Object value) { setParameter(++addPos, value); } - - public SqlUpdate setParameter(int position, Object value) { - bindParams.setParameter(position, value); - return this; - } - public SqlUpdate setNull(int position, int jdbcType) { - bindParams.setNullParameter(position, jdbcType); - return this; - } + public SqlUpdate setParameter(int position, Object value) { + bindParams.setParameter(position, value); + return this; + } - public SqlUpdate setNullParameter(int position, int jdbcType) { - bindParams.setNullParameter(position, jdbcType); - return this; - } + public SqlUpdate setNull(int position, int jdbcType) { + bindParams.setNullParameter(position, jdbcType); + return this; + } - public SqlUpdate setParameter(String name, Object param) { - bindParams.setParameter(name, param); - return this; - } + public SqlUpdate setNullParameter(int position, int jdbcType) { + bindParams.setNullParameter(position, jdbcType); + return this; + } - public SqlUpdate setNull(String name, int jdbcType) { - bindParams.setNullParameter(name, jdbcType); - return this; - } + public SqlUpdate setParameter(String name, Object param) { + bindParams.setParameter(name, param); + return this; + } - public SqlUpdate setNullParameter(String name, int jdbcType) { - bindParams.setNullParameter(name, jdbcType); - return this; - } + public SqlUpdate setNull(String name, int jdbcType) { + bindParams.setNullParameter(name, jdbcType); + return this; + } - /** - * Return the bind parameters. - */ - public BindParams getBindParams() { - return bindParams; - } + public SqlUpdate setNullParameter(String name, int jdbcType) { + bindParams.setNullParameter(name, jdbcType); + return this; + } + + /** + * Return the bind parameters. + */ + public BindParams getBindParams() { + return bindParams; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java b/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java index a59866716..0a0535dd5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java @@ -71,11 +71,11 @@ public class DiffHelp { iterator.remove(); } else if (beanProperty instanceof BeanPropertyAssocOne) { - BeanPropertyAssocOne assoc = (BeanPropertyAssocOne)beanProperty; + BeanPropertyAssocOne assoc = (BeanPropertyAssocOne) beanProperty; if (!assoc.isEmbedded()) { // flatten for assoc one beans if (flattened == null) { - flattened = new LinkedHashMap(); + flattened = new LinkedHashMap<>(); } flattenToId(flattened, entry, beanProperty, assoc); iterator.remove(); @@ -90,13 +90,13 @@ public class DiffHelp { return values; } - private static void flattenToId(Map flattened, Map.Entry entry, BeanProperty beanProperty, BeanPropertyAssocOne assoc) { + private static void flattenToId(Map flattened, Map.Entry entry, BeanProperty beanProperty, BeanPropertyAssocOne assoc) { BeanDescriptor oneDesc = assoc.getTargetDescriptor(); ValuePair value = entry.getValue(); - Object newId = value.getNewValue() == null ? null : oneDesc.getId((EntityBean)value.getNewValue()); - Object oldId = value.getOldValue() == null ? null : oneDesc.getId((EntityBean)value.getOldValue()); + Object newId = value.getNewValue() == null ? null : oneDesc.getId((EntityBean) value.getNewValue()); + Object oldId = value.getOldValue() == null ? null : oneDesc.getId((EntityBean) value.getOldValue()); String propName = beanProperty.getName() + "." + oneDesc.getIdProperty().getName(); flattened.put(propName, new ValuePair(newId, oldId)); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java b/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java index a9ee3282e..5bdcb71f0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java @@ -5,33 +5,33 @@ import java.util.HashMap; /** * Used to reduce memory consumption of strings used in deployment processing. *

- * Using this for now instead of String.intern() to avoid any unexpected + * Using this for now instead of String.intern() to avoid any unexpected * increase in PermGen space. *

*/ public final class InternString { - private static final HashMap map = new HashMap(); - - - /** - * Return the shared instance of this string. - */ - public static String intern(String s){ - - if (s == null){ - return null; - } - - synchronized (map) { - String v = map.get(s); - if (v != null){ - return v; - } else { - map.put(s, s); - return s; - } - - } - } + private static final HashMap map = new HashMap<>(); + + + /** + * Return the shared instance of this string. + */ + public static String intern(String s) { + + if (s == null) { + return null; + } + + synchronized (map) { + String v = map.get(s); + if (v != null) { + return v; + } else { + map.put(s, s); + return s; + } + + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java b/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java index caf82e185..25665cfd4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java @@ -108,7 +108,7 @@ public class InternalConfiguration { /** * List of plugins (that ultimately the DefaultServer configures late in construction). */ - private final List plugins = new ArrayList(); + private final List plugins = new ArrayList<>(); public InternalConfiguration(ClusterManager clusterManager, ServerCacheManager cacheManager, SpiBackgroundExecutor backgroundExecutor, diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/Message.java b/src/main/java/com/avaje/ebeaninternal/server/core/Message.java index b129864b9..d0f1edd84 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/Message.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/Message.java @@ -9,56 +9,56 @@ import java.util.ResourceBundle; */ public class Message { - private static final String bundle = "com.avaje.ebeaninternal.api.message"; + private static final String bundle = "com.avaje.ebeaninternal.api.message"; - /** - * Return a message that has a single argument. - */ - public static String msg(String key, Object arg) { - Object[] args = new Object[1]; - args[0] = arg; - return MessageFormat.format(getPattern(key), args); - } + /** + * Return a message that has a single argument. + */ + public static String msg(String key, Object arg) { + Object[] args = new Object[1]; + args[0] = arg; + return MessageFormat.format(getPattern(key), args); + } - /** - * Return a message that has a two arguments. - */ - public static String msg(String key, Object arg, Object arg2) { - Object[] args = new Object[2]; - args[0] = arg; - args[1] = arg2; - return MessageFormat.format(getPattern(key), args); - } + /** + * Return a message that has a two arguments. + */ + public static String msg(String key, Object arg, Object arg2) { + Object[] args = new Object[2]; + args[0] = arg; + args[1] = arg2; + return MessageFormat.format(getPattern(key), args); + } - public static String msg(String key, Object arg, Object arg2, Object arg3) { - Object[] args = new Object[3]; - args[0] = arg; - args[1] = arg2; - args[2] = arg3; - return MessageFormat.format(getPattern(key), args); - } + public static String msg(String key, Object arg, Object arg2, Object arg3) { + Object[] args = new Object[3]; + args[0] = arg; + args[1] = arg2; + args[2] = arg3; + return MessageFormat.format(getPattern(key), args); + } - /** - * Return a message that has an array of arguments. - */ - public static String msg(String key, Object[] args) { - return MessageFormat.format(getPattern(key), args); - } + /** + * Return a message that has an array of arguments. + */ + public static String msg(String key, Object[] args) { + return MessageFormat.format(getPattern(key), args); + } - /** - * Return a message that has a no arguments. - */ - public static String msg(String key) { - return MessageFormat.format(getPattern(key), new Object[0]); - } + /** + * Return a message that has a no arguments. + */ + public static String msg(String key) { + return MessageFormat.format(getPattern(key), new Object[0]); + } - private static String getPattern(String key) { - try { - ResourceBundle myResources = ResourceBundle.getBundle(bundle); - return myResources.getString(key); - } catch (MissingResourceException e) { - return "MissingResource " + bundle + ":" + key; - } + private static String getPattern(String key) { + try { + ResourceBundle myResources = ResourceBundle.getBundle(bundle); + return myResources.getString(key); + } catch (MissingResourceException e) { + return "MissingResource " + bundle + ":" + key; } - + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/OrmQueryRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/OrmQueryRequest.java index 5b1a74340..a0d98ec3e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/OrmQueryRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/OrmQueryRequest.java @@ -449,7 +449,7 @@ public final class OrmQueryRequest extends BeanRequest implements BeanQueryRe if (cached != null && isAuditReads() && readAuditQueryType()) { // raw sql can't use L2 cache so normal queries only in here Collection actualDetails = cached.getActualDetails(); - List ids = new ArrayList(actualDetails.size()); + List ids = new ArrayList<>(actualDetails.size()); for (T bean : actualDetails) { ids.add(beanDescriptor.getIdForJson(bean)); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequest.java index faa8d432b..17d9618b4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequest.java @@ -11,36 +11,36 @@ import com.avaje.ebeaninternal.server.persist.PersistExecute; */ public abstract class PersistRequest extends BeanRequest implements BatchPostExecute { - public enum Type { - INSERT, UPDATE, DELETE, SOFT_DELETE, DELETE_PERMANENT, UPDATESQL, CALLABLESQL - } + public enum Type { + INSERT, UPDATE, DELETE, SOFT_DELETE, DELETE_PERMANENT, UPDATESQL, CALLABLESQL + } - protected boolean persistCascade; - - /** - * One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL. - */ - protected Type type; - - protected final PersistExecute persistExecute; + protected boolean persistCascade; /** - * Used by CallableSqlRequest and UpdateSqlRequest. - */ - public PersistRequest(SpiEbeanServer server, SpiTransaction t, PersistExecute persistExecute) { - super(server, t); - this.persistExecute = persistExecute; - } - - /** - * Execute a the request or queue/batch it for later execution. - */ - public abstract int executeOrQueue(); + * One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL. + */ + protected Type type; - /** - * Execute the request right now. - */ - public abstract int executeNow(); + protected final PersistExecute persistExecute; + + /** + * Used by CallableSqlRequest and UpdateSqlRequest. + */ + public PersistRequest(SpiEbeanServer server, SpiTransaction t, PersistExecute persistExecute) { + super(server, t); + this.persistExecute = persistExecute; + } + + /** + * Execute a the request or queue/batch it for later execution. + */ + public abstract int executeOrQueue(); + + /** + * Execute the request right now. + */ + public abstract int executeNow(); public boolean isLogSql() { return transaction.isLogSql(); @@ -58,47 +58,47 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe return transaction.isBatchThisRequest(type); } - /** - * Execute the statement. - */ - public int executeStatement() { - - boolean batch = isBatchThisRequest(); + /** + * Execute the statement. + */ + public int executeStatement() { - int rows; - BatchControl control = transaction.getBatchControl(); - if (control != null) { - rows = control.executeStatementOrBatch(this, batch); - - } else if (batch) { - // need to create the BatchControl - control = persistExecute.createBatchControl(transaction); - rows = control.executeStatementOrBatch(this, true); - } else { - rows = executeNow(); - } - - return rows; - } + boolean batch = isBatchThisRequest(); + + int rows; + BatchControl control = transaction.getBatchControl(); + if (control != null) { + rows = control.executeStatementOrBatch(this, batch); + + } else if (batch) { + // need to create the BatchControl + control = persistExecute.createBatchControl(transaction); + rows = control.executeStatementOrBatch(this, true); + } else { + rows = executeNow(); + } + + return rows; + } public void initTransIfRequired() { - createImplicitTransIfRequired(); - persistCascade = transaction.isPersistCascade(); - } + createImplicitTransIfRequired(); + persistCascade = transaction.isPersistCascade(); + } - /** - * Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL - * or CALLABLESQL. - */ - public Type getType() { - return type; - } + /** + * Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL + * or CALLABLESQL. + */ + public Type getType() { + return type; + } + + /** + * Return true if save and delete should cascade. + */ + public boolean isPersistCascade() { + return persistCascade; + } - /** - * Return true if save and delete should cascade. - */ - public boolean isPersistCascade() { - return persistCascade; - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index c38f9b257..23a2e910a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -233,6 +233,15 @@ public final class PersistRequestBean extends PersistRequest implements BeanP } } + @Override + public void rollbackTransIfRequired() { + if (batchOnCascadeSet) { + transaction.flushBatchOnRollback(); + batchOnCascadeSet = false; + } + super.rollbackTransIfRequired(); + } + /** * Return true is this request was added to the JDBC batch. */ @@ -303,8 +312,8 @@ public final class PersistRequestBean extends PersistRequest implements BeanP */ public boolean hasDirtyProperty(int[] propertyPositions) { - for (int i = 0; i < propertyPositions.length; i++) { - if (dirtyProperties[propertyPositions[i]]) { + for (int propertyPosition : propertyPositions) { + if (dirtyProperties[propertyPosition]) { return true; } } @@ -366,6 +375,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Process the persist request updating the document store. */ + @Override public void docStoreUpdate(DocStoreUpdateContext txn) throws IOException { switch (type) { @@ -387,6 +397,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Add this event to the queue entries in IndexUpdates. */ + @Override public void addToQueue(DocStoreUpdates docStoreUpdates) { switch (type) { case INSERT: @@ -458,7 +469,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP private Integer getBeanHash() { if (beanHash == null) { Object id = beanDescriptor.getId(entityBean); - int hc = 31 * bean.getClass().getName().hashCode(); + int hc = 92821 * bean.getClass().getName().hashCode(); if (id != null) { hc += id.hashCode(); } @@ -550,6 +561,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Return the bean associated with this request. */ + @Override public T getBean() { return bean; } @@ -700,6 +712,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Set the generated key back to the bean. Only used for inserts with getGeneratedKeys. */ + @Override public void setGeneratedKey(Object idValue) { if (idValue != null) { // remember it for logging summary @@ -718,6 +731,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Check for optimistic concurrency exception. */ + @Override public final void checkRowCount(int rowCount) { if (ConcurrencyMode.VERSION == concurrencyMode && rowCount != 1) { String m = Message.msg("persist.conc2", "" + rowCount); @@ -761,6 +775,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Post processing. */ + @Override public void postExecute() { changeLog(); @@ -911,7 +926,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP */ public void addUpdatedManyProperty(BeanPropertyAssocMany updatedAssocMany) { if (updatedManys == null) { - updatedManys = new ArrayList>(5); + updatedManys = new ArrayList<>(5); } updatedManys.add(updatedAssocMany); } @@ -968,6 +983,8 @@ public final class PersistRequestBean extends PersistRequest implements BeanP docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue); } } + default: + break; } } @@ -1013,12 +1030,12 @@ public final class PersistRequestBean extends PersistRequest implements BeanP BeanProperty versionProperty = beanDescriptor.getVersionProperty(); if (versionProperty != null) { if (intercept.isLoadedProperty(versionProperty.getPropertyIndex())) { - hash = hash * 31 + 7; + hash = hash * 92821 + 7; } } if (publish) { - hash = hash * 31; + hash = hash * 92821; } return hash; diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java index 56ae7e7b3..b2db58e0b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java @@ -1,9 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.sql.CallableStatement; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.CallableSql; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.BindParams.Param; @@ -13,135 +9,138 @@ import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.api.TransactionEventTable; import com.avaje.ebeaninternal.server.persist.PersistExecute; +import java.sql.CallableStatement; +import java.sql.SQLException; +import java.util.List; + /** * Persist request specifically for CallableSql. */ public final class PersistRequestCallableSql extends PersistRequest { - private final SpiCallableSql callableSql; + private final SpiCallableSql callableSql; - private int rowCount; + private int rowCount; - private String bindLog; + private String bindLog; - private CallableStatement cstmt; + private CallableStatement cstmt; - private BindParams bindParam; + private BindParams bindParam; - /** - * Create. - */ - public PersistRequestCallableSql(SpiEbeanServer server, - CallableSql cs, SpiTransaction t, PersistExecute persistExecute) { - - super(server, t, persistExecute); - this.type = PersistRequest.Type.CALLABLESQL; - this.callableSql = (SpiCallableSql)cs; - } - - @Override - public int executeOrQueue() { - return executeStatement(); - } + /** + * Create. + */ + public PersistRequestCallableSql(SpiEbeanServer server, + CallableSql cs, SpiTransaction t, PersistExecute persistExecute) { - @Override - public int executeNow() { - return persistExecute.executeSqlCallable(this); - } + super(server, t, persistExecute); + this.type = PersistRequest.Type.CALLABLESQL; + this.callableSql = (SpiCallableSql) cs; + } - /** - * Return the CallableSql. - */ - public SpiCallableSql getCallableSql() { - return callableSql; - } + @Override + public int executeOrQueue() { + return executeStatement(); + } - /** - * The the log of bind values. - */ - public void setBindLog(String bindLog) { - this.bindLog = bindLog; - } + @Override + public int executeNow() { + return persistExecute.executeSqlCallable(this); + } - /** - * Note the rowCount of the execution. - */ - public void checkRowCount(int count) { - this.rowCount = count; - } + /** + * Return the CallableSql. + */ + public SpiCallableSql getCallableSql() { + return callableSql; + } - /** - * Only called for insert with generated keys. - */ - public void setGeneratedKey(Object idValue) { - } + /** + * The the log of bind values. + */ + public void setBindLog(String bindLog) { + this.bindLog = bindLog; + } - /** - * Perform post execute processing for the CallableSql. - */ - public void postExecute() { + /** + * Note the rowCount of the execution. + */ + public void checkRowCount(int count) { + this.rowCount = count; + } - if (transaction.isLogSummary()) { - String m = "CallableSql label[" + callableSql.getLabel() + "]" + " rows[" + rowCount+ "]" + " bind[" + bindLog + "]"; - transaction.logSummary(m); - } + /** + * Only called for insert with generated keys. + */ + public void setGeneratedKey(Object idValue) { + } - // register table modifications with the transaction event - TransactionEventTable tableEvents = callableSql.getTransactionEventTable(); - - if (tableEvents != null && !tableEvents.isEmpty()) { - transaction.getEvent().add(tableEvents); - } else { - transaction.markNotQueryOnly(); - } + /** + * Perform post execute processing for the CallableSql. + */ + public void postExecute() { - } + if (transaction.isLogSummary()) { + String m = "CallableSql label[" + callableSql.getLabel() + "]" + " rows[" + rowCount + "]" + " bind[" + bindLog + "]"; + transaction.logSummary(m); + } - /** - * These need to be set for use with Non-batch execution. Specifically to - * read registered out parameters and potentially handle the - * executeOverride() method. - */ - public void setBound(BindParams bindParam, CallableStatement cstmt) { - this.bindParam = bindParam; - this.cstmt = cstmt; - } + // register table modifications with the transaction event + TransactionEventTable tableEvents = callableSql.getTransactionEventTable(); - /** - * Execute the statement in normal non batch mode. - */ - public int executeUpdate() throws SQLException { + if (tableEvents != null && !tableEvents.isEmpty()) { + transaction.getEvent().add(tableEvents); + } else { + transaction.markNotQueryOnly(); + } - // check to see if the execution has been overridden - // only works in non-batch mode - if (callableSql.executeOverride(cstmt)) { - return -1; - // // been overridden so just return the rowCount - // rowCount = callableSql.getRowCount(); - // return rowCount; - } + } - rowCount = cstmt.executeUpdate(); + /** + * These need to be set for use with Non-batch execution. Specifically to + * read registered out parameters and potentially handle the + * executeOverride() method. + */ + public void setBound(BindParams bindParam, CallableStatement cstmt) { + this.bindParam = bindParam; + this.cstmt = cstmt; + } - // only read in non-batch mode - readOutParams(); + /** + * Execute the statement in normal non batch mode. + */ + public int executeUpdate() throws SQLException { - return rowCount; - } + // check to see if the execution has been overridden + // only works in non-batch mode + if (callableSql.executeOverride(cstmt)) { + return -1; + // // been overridden so just return the rowCount + // rowCount = callableSql.getRowCount(); + // return rowCount; + } - private void readOutParams() throws SQLException { + rowCount = cstmt.executeUpdate(); - List list = bindParam.positionedParameters(); - int pos = 0; + // only read in non-batch mode + readOutParams(); - for (int i = 0; i < list.size(); i++) { - pos++; - BindParams.Param param = list.get(i); - if (param.isOutParam()) { - Object outValue = cstmt.getObject(pos); - param.setOutValue(outValue); - } - } - } + return rowCount; + } + + private void readOutParams() throws SQLException { + + List list = bindParam.positionedParameters(); + int pos = 0; + + for (Param param : list) { + pos++; + if (param.isOutParam()) { + Object outValue = cstmt.getObject(pos); + param.setOutValue(outValue); + } + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java index 78c37b9b4..70f7d099e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java @@ -13,98 +13,98 @@ import com.avaje.ebeaninternal.server.persist.PersistExecute; */ public final class PersistRequestOrmUpdate extends PersistRequest { - private final BeanDescriptor beanDescriptor; - - private final SpiUpdate ormUpdate; + private final BeanDescriptor beanDescriptor; - private int rowCount; + private final SpiUpdate ormUpdate; - private String bindLog; + private int rowCount; - /** - * Create. - */ - public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager mgr, SpiUpdate ormUpdate, - SpiTransaction t, PersistExecute persistExecute) { - - super(server, t, persistExecute); - this.beanDescriptor = mgr.getBeanDescriptor(); - this.ormUpdate = ormUpdate; - } - - public BeanDescriptor getBeanDescriptor() { - return beanDescriptor; - } - - @Override - public int executeNow() { - return persistExecute.executeOrmUpdate(this); - } + private String bindLog; - @Override - public int executeOrQueue() { - return executeStatement(); - } + /** + * Create. + */ + public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager mgr, SpiUpdate ormUpdate, + SpiTransaction t, PersistExecute persistExecute) { + + super(server, t, persistExecute); + this.beanDescriptor = mgr.getBeanDescriptor(); + this.ormUpdate = ormUpdate; + } + + public BeanDescriptor getBeanDescriptor() { + return beanDescriptor; + } + + @Override + public int executeNow() { + return persistExecute.executeOrmUpdate(this); + } + + @Override + public int executeOrQueue() { + return executeStatement(); + } - /** - * Return the UpdateSql. - */ - public SpiUpdate getOrmUpdate() { - return ormUpdate; - } + /** + * Return the UpdateSql. + */ + public SpiUpdate getOrmUpdate() { + return ormUpdate; + } - /** - * No concurrency checking so just note the rowCount. - */ - public void checkRowCount(int count) { - this.rowCount = count; - } + /** + * No concurrency checking so just note the rowCount. + */ + public void checkRowCount(int count) { + this.rowCount = count; + } - /** - * Not called for this type of request. - */ - public void setGeneratedKey(Object idValue) { - } + /** + * Not called for this type of request. + */ + public void setGeneratedKey(Object idValue) { + } - /** - * Set the bound values. - */ - public void setBindLog(String bindLog) { - this.bindLog = bindLog; - } + /** + * Set the bound values. + */ + public void setBindLog(String bindLog) { + this.bindLog = bindLog; + } - /** - * Perform post execute processing. - */ - public void postExecute() { + /** + * Perform post execute processing. + */ + public void postExecute() { - OrmUpdateType ormUpdateType = ormUpdate.getOrmUpdateType(); - String tableName = ormUpdate.getBaseTable(); - - if (transaction.isLogSummary()) { - String m = ormUpdateType + " table[" + tableName + "] rows["+ rowCount + "] bind[" + bindLog + "]"; - transaction.logSummary(m); - } - - if (ormUpdate.isNotifyCache()) { - - // add the modification info to the TransactionEvent - // this is used to invalidate cached objects etc - switch (ormUpdateType) { - case INSERT: - transaction.getEvent().add(tableName, true, false, false); - break; - case UPDATE: - transaction.getEvent().add(tableName, false, true, false); - break; - case DELETE: - transaction.getEvent().add(tableName, false, false, true); - break; - default: - break; - } - } - } + OrmUpdateType ormUpdateType = ormUpdate.getOrmUpdateType(); + String tableName = ormUpdate.getBaseTable(); + + if (transaction.isLogSummary()) { + String m = ormUpdateType + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]"; + transaction.logSummary(m); + } + + if (ormUpdate.isNotifyCache()) { + + // add the modification info to the TransactionEvent + // this is used to invalidate cached objects etc + switch (ormUpdateType) { + case INSERT: + transaction.getEvent().add(tableName, true, false, false); + break; + case UPDATE: + transaction.getEvent().add(tableName, false, true, false); + break; + case DELETE: + transaction.getEvent().add(tableName, false, false, true); + break; + default: + break; + } + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java b/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java index 512b62525..89797b8fe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java @@ -1,8 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.util.Collection; -import java.util.List; - import com.avaje.ebean.CallableSql; import com.avaje.ebean.Query; import com.avaje.ebean.SqlUpdate; @@ -10,6 +7,9 @@ import com.avaje.ebean.Transaction; import com.avaje.ebean.Update; import com.avaje.ebean.bean.EntityBean; +import java.util.Collection; +import java.util.List; + /** * API for persisting a bean. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java index a43845e0a..37018c04b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java @@ -138,7 +138,7 @@ public final class RelationalQueryRequest { */ private String[] getPropertyNames() throws SQLException { - ArrayList propNames = new ArrayList(); + ArrayList propNames = new ArrayList<>(); ResultSetMetaData metaData = resultSet.getMetaData(); int columnsPlusOne = metaData.getColumnCount() + 1; @@ -191,10 +191,10 @@ public final class RelationalQueryRequest { SqlRow sqlRow = new DefaultSqlRow(estimateCapacity, 0.75f, dbTrueValue); int index = 0; - for (int i = 0; i < propertyNames.length; i++) { + for (String propertyName : propertyNames) { index++; Object value = resultSet.getObject(index); - sqlRow.set(propertyNames[i], value); + sqlRow.set(propertyName, value); } return sqlRow; } @@ -218,8 +218,7 @@ public final class RelationalQueryRequest { int firstRow = query.getFirstRow(); int maxRows = query.getMaxRows(); if (firstRow > 0 || maxRows > 0) { - return ebeanServer.getDatabasePlatform().getBasicSqlLimiter() - .limit(sql, firstRow, maxRows); + return ebeanServer.getDatabasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows); } return sql; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/ServletContextListener.java b/src/main/java/com/avaje/ebeaninternal/server/core/ServletContextListener.java index a00613e1e..f9486be50 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/ServletContextListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/ServletContextListener.java @@ -6,7 +6,6 @@ import javax.servlet.ServletContextEvent; /** * Listens for webserver server starting and stopping events. - * *

* Register this listener in the web.xml configuration file. This will listen * for startup and shutdown events. @@ -14,18 +13,18 @@ import javax.servlet.ServletContextEvent; */ public class ServletContextListener implements javax.servlet.ServletContextListener { - /** - * The servlet container is stopping. - */ - public void contextDestroyed(ServletContextEvent event) { - ShutdownManager.shutdown(); - } + /** + * The servlet container is stopping. + */ + public void contextDestroyed(ServletContextEvent event) { + ShutdownManager.shutdown(); + } - /** - * Do nothing on startup. - */ - public void contextInitialized(ServletContextEvent event) { + /** + * Do nothing on startup. + */ + public void contextInitialized(ServletContextEvent event) { + + } - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/TransWrapper.java b/src/main/java/com/avaje/ebeaninternal/server/core/TransWrapper.java index 36fb3de0f..e1cdf36ac 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/TransWrapper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/TransWrapper.java @@ -11,17 +11,17 @@ import com.avaje.ebeaninternal.api.SpiTransaction; */ final class TransWrapper { - final SpiTransaction transaction; + final SpiTransaction transaction; - private final boolean wasCreated; + private final boolean wasCreated; - /** - * Wrap the transaction indicating if it was just created. - */ - TransWrapper(SpiTransaction t, boolean created) { - transaction = t; - wasCreated = created; - } + /** + * Wrap the transaction indicating if it was just created. + */ + TransWrapper(SpiTransaction t, boolean created) { + transaction = t; + wasCreated = created; + } void batchEscalateOnCollection() { transaction.checkBatchEscalationOnCollection(); @@ -33,24 +33,24 @@ final class TransWrapper { } } - void commitIfCreated() { - if (wasCreated){ - transaction.commit(); - } - } - - void rollbackIfCreated() { - if (wasCreated){ - transaction.rollbackIfActive(); - } - } - - /** - * Return true if the transaction was just created. If true it should be - * committed after the request has been processed. - */ - boolean wasCreated() { - return wasCreated; - } + void commitIfCreated() { + if (wasCreated) { + transaction.commit(); + } + } -} \ No newline at end of file + void rollbackIfCreated() { + if (wasCreated) { + transaction.rollbackIfActive(); + } + } + + /** + * Return true if the transaction was just created. If true it should be + * committed after the request has been processed. + */ + boolean wasCreated() { + return wasCreated; + } + +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClassPathSearch.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClassPathSearch.java index a0bd0178c..f5641eed1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClassPathSearch.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClassPathSearch.java @@ -6,7 +6,8 @@ import org.avaje.classpath.scanner.ClassPathScanner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; +import java.util.List; +import java.util.Set; /** * Searches for interesting classes such as Entities, Embedded and ScalarTypes. diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClasses.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClasses.java index 3df277068..6fb8d9602 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClasses.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClasses.java @@ -38,45 +38,45 @@ public class BootupClasses implements ClassFilter { private static final Logger logger = LoggerFactory.getLogger(BootupClasses.class); - private final List> embeddableList = new ArrayList>(); + private final List> embeddableList = new ArrayList<>(); - private final List> entityList = new ArrayList>(); + private final List> entityList = new ArrayList<>(); - private final List>> scalarTypeList = new ArrayList>>(); + private final List>> scalarTypeList = new ArrayList<>(); - private final List>> scalarConverterList = new ArrayList>>(); + private final List>> scalarConverterList = new ArrayList<>(); - private final List>> compoundTypeList = new ArrayList>>(); + private final List>> compoundTypeList = new ArrayList<>(); // The following objects are instantiiated on first request // there is always a candidate list, that holds the class and an // instance list, that holds the instance. Once a class is instantiiated // (or added) it will get removed from the candidate list - private final List> idGeneratorCandidates = new ArrayList>(); + private final List> idGeneratorCandidates = new ArrayList<>(); - private final List> beanPersistControllerCandidates = new ArrayList>(); + private final List> beanPersistControllerCandidates = new ArrayList<>(); - private final List> beanPostLoadCandidates = new ArrayList>(); + private final List> beanPostLoadCandidates = new ArrayList<>(); - private final List> beanPostConstructListenerCandidates = new ArrayList>(); + private final List> beanPostConstructListenerCandidates = new ArrayList<>(); - private final List> beanFindControllerCandidates = new ArrayList>(); + private final List> beanFindControllerCandidates = new ArrayList<>(); - private final List> beanPersistListenerCandidates = new ArrayList>(); + private final List> beanPersistListenerCandidates = new ArrayList<>(); - private final List> beanQueryAdapterCandidates = new ArrayList>(); + private final List> beanQueryAdapterCandidates = new ArrayList<>(); - private final List> serverConfigStartupCandidates = new ArrayList>(); + private final List> serverConfigStartupCandidates = new ArrayList<>(); - private final List idGeneratorInstances = new ArrayList(); - private final List beanPersistControllerInstances = new ArrayList(); - private final List beanPostLoadInstances = new ArrayList(); - private final List beanPostConstructListenerInstances = new ArrayList(); - private final List beanFindControllerInstances = new ArrayList(); - private final List beanPersistListenerInstances = new ArrayList(); - private final List beanQueryAdapterInstances = new ArrayList(); - private final List serverConfigStartupInstances = new ArrayList(); + private final List idGeneratorInstances = new ArrayList<>(); + private final List beanPersistControllerInstances = new ArrayList<>(); + private final List beanPostLoadInstances = new ArrayList<>(); + private final List beanPostConstructListenerInstances = new ArrayList<>(); + private final List beanFindControllerInstances = new ArrayList<>(); + private final List beanPersistListenerInstances = new ArrayList<>(); + private final List beanQueryAdapterInstances = new ArrayList<>(); + private final List serverConfigStartupInstances = new ArrayList<>(); // single objects private Class changeLogPrepareClass; diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java index a1b978d21..6dbfb865a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java @@ -17,11 +17,11 @@ class DistillPackages { static List distill(Collection packages, Collection mfPackages) { // sort into natural order - TreeSet treeSet = new TreeSet(); + TreeSet treeSet = new TreeSet<>(); treeSet.addAll(packages); treeSet.addAll(mfPackages); - List distilled = new ArrayList(); + List distilled = new ArrayList<>(); // build the distilled list for (String pack : treeSet) { @@ -38,8 +38,8 @@ class DistillPackages { */ private static boolean notAlreadyContained(List distilled, String pack) { - for (int i = 0; i < distilled.size(); i++) { - if (pack.startsWith(distilled.get(i))) { + for (String aDistilled : distilled) { + if (pack.startsWith(aDistilled)) { return false; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java index 37b734bd9..3acfb8996 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java @@ -19,19 +19,19 @@ class ManifestReader { private static final Logger logger = LoggerFactory.getLogger(ManifestReader.class); - private final Set packageSet = new HashSet(); + private final Set packageSet = new HashSet<>(); /** * Read the packages from ebean.mf manifest files found as resources. */ - static Set readManifests(ClassLoader classLoader, String resourcePath) { + static Set readManifests(ClassLoader classLoader, String resourcePath) { return new ManifestReader().read(classLoader, resourcePath); } /** * Read all the specific manifest files and return the set of packages containing type query beans. */ - private Set read(ClassLoader classLoader, String resourcePath) { + private Set read(ClassLoader classLoader, String resourcePath) { try { Enumeration resources = classLoader.getResources(resourcePath); @@ -74,8 +74,8 @@ class ManifestReader { */ private void add(String packages) { String[] split = packages.split(",|;| "); - for (int i = 0; i - - Core implementation objects + + Core implementation objects Core implementation objects - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/timezone/CloneDataTimeZone.java b/src/main/java/com/avaje/ebeaninternal/server/core/timezone/CloneDataTimeZone.java index e0cd52f6c..4f18d653d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/timezone/CloneDataTimeZone.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/timezone/CloneDataTimeZone.java @@ -17,6 +17,6 @@ public class CloneDataTimeZone extends SimpleDataTimeZone { @Override public Calendar getTimeZone() { // return cloned copy for Oracle to muck around with - return (Calendar)zone.clone(); + return (Calendar) zone.clone(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelp.java index 4fe99bdb9..307698334 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelp.java @@ -12,11 +12,11 @@ import java.sql.SQLException; */ abstract class AssocOneHelp { - protected final BeanPropertyAssocOne property; + protected final BeanPropertyAssocOne property; - protected final BeanDescriptor target; + protected final BeanDescriptor target; - AssocOneHelp(BeanPropertyAssocOne property) { + AssocOneHelp(BeanPropertyAssocOne property) { this.property = property; this.target = property.targetDescriptor; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpEmbedded.java index ba69d7b2e..b1e3bd45b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpEmbedded.java @@ -9,7 +9,7 @@ import java.sql.SQLException; */ final class AssocOneHelpEmbedded extends AssocOneHelp { - public AssocOneHelpEmbedded(BeanPropertyAssocOne property) { + public AssocOneHelpEmbedded(BeanPropertyAssocOne property) { super(property); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefExported.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefExported.java index c0ff608f2..318a158a3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefExported.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefExported.java @@ -7,7 +7,7 @@ import com.avaje.ebeaninternal.server.query.SqlJoinType; */ class AssocOneHelpRefExported extends AssocOneHelp { - public AssocOneHelpRefExported(BeanPropertyAssocOne property) { + public AssocOneHelpRefExported(BeanPropertyAssocOne property) { super(property); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefInherit.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefInherit.java index 4791cb641..6ec408677 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefInherit.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefInherit.java @@ -13,7 +13,7 @@ class AssocOneHelpRefInherit extends AssocOneHelp { private final InheritInfo inherit; - AssocOneHelpRefInherit(BeanPropertyAssocOne property) { + AssocOneHelpRefInherit(BeanPropertyAssocOne property) { super(property); this.inherit = property.targetInheritInfo; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefSimple.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefSimple.java index 72dd6a533..f84e861cf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefSimple.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefSimple.java @@ -5,7 +5,7 @@ package com.avaje.ebeaninternal.server.deploy; */ class AssocOneHelpRefSimple extends AssocOneHelp { - AssocOneHelpRefSimple(BeanPropertyAssocOne property) { + AssocOneHelpRefSimple(BeanPropertyAssocOne property) { super(property); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCascadeInfo.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCascadeInfo.java index c35d6f532..3ac26d4b7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCascadeInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCascadeInfo.java @@ -17,8 +17,8 @@ public class BeanCascadeInfo { private boolean refresh; public void setTypes(CascadeType[] types) { - for (int i = 0; i < types.length; i++) { - setType(types[i]); + for (CascadeType type : types) { + setType(type); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCollectionHelpFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCollectionHelpFactory.java index 827be9818..fcf14366a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCollectionHelpFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCollectionHelpFactory.java @@ -21,11 +21,11 @@ public class BeanCollectionHelpFactory { ManyType manyType = manyProperty.getManyType(); switch (manyType) { case LIST: - return new BeanListHelp(manyProperty); + return new BeanListHelp<>(manyProperty); case SET: - return new BeanSetHelp(manyProperty); + return new BeanSetHelp<>(manyProperty); case MAP: - return new BeanMapHelp(manyProperty); + return new BeanMapHelp<>(manyProperty); default: throw new RuntimeException("Invalid type " + manyType); } @@ -46,7 +46,7 @@ public class BeanCollectionHelpFactory { } else { BeanDescriptor target = request.getBeanDescriptor(); String mapKey = request.getQuery().getMapKey(); - return new BeanMapHelp(target, mapKey); + return new BeanMapHelp<>(target, mapKey); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java index b04cd4218..8d8c17d7a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java @@ -85,6 +85,7 @@ import javax.persistence.PersistenceException; import java.io.IOException; import java.lang.reflect.Modifier; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.sql.Types; import java.util.ArrayList; import java.util.Collection; @@ -101,15 +102,15 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { private static final Logger logger = LoggerFactory.getLogger(BeanDescriptor.class); - private final ConcurrentHashMap updatePlanCache = new ConcurrentHashMap(); + private final ConcurrentHashMap updatePlanCache = new ConcurrentHashMap<>(); - private final ConcurrentHashMap queryPlanCache = new ConcurrentHashMap(); + private final ConcurrentHashMap queryPlanCache = new ConcurrentHashMap<>(); - private final ConcurrentHashMap elCache = new ConcurrentHashMap(); + private final ConcurrentHashMap elCache = new ConcurrentHashMap<>(); - private final ConcurrentHashMap elDeployCache = new ConcurrentHashMap(); + private final ConcurrentHashMap elDeployCache = new ConcurrentHashMap<>(); - private final ConcurrentHashMap> comparatorCache = new ConcurrentHashMap>(); + private final ConcurrentHashMap> comparatorCache = new ConcurrentHashMap<>(); private final Map namedRawSql; @@ -492,16 +493,16 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { boolean noRelationships = propertiesOne.length + propertiesMany.length == 0; this.cacheSharableBeans = noRelationships && deploy.getCacheOptions().isReadOnly(); - this.cacheHelp = new BeanDescriptorCacheHelp(this, owner.getCacheManager(), deploy.getCacheOptions(), cacheSharableBeans, propertiesOneImported); - this.jsonHelp = new BeanDescriptorJsonHelp(this); - this.draftHelp = new BeanDescriptorDraftHelp(this); + this.cacheHelp = new BeanDescriptorCacheHelp<>(this, owner.getCacheManager(), deploy.getCacheOptions(), cacheSharableBeans, propertiesOneImported); + this.jsonHelp = new BeanDescriptorJsonHelp<>(this); + this.draftHelp = new BeanDescriptorDraftHelp<>(this); this.docStoreAdapter = owner.createDocStoreBeanAdapter(this, deploy); this.docStoreQueueId = docStoreAdapter.getQueueId(); // Check if there are no cascade save associated beans ( subject to change - // in initialiseOther()). Note that if we are in an inheritance hierarchy - // then we also need to check every BeanDescriptors in the InheritInfo as + // in initialiseOther()). Note that if we are in an inheritance hierarchy + // then we also need to check every BeanDescriptors in the InheritInfo as // well. We do that later in initialiseOther(). saveRecurseSkippable = (0 == (propertiesOneExportedSave.length + propertiesOneImportedSave.length + propertiesManySave.length)); @@ -588,9 +589,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void setEbeanServer(SpiEbeanServer ebeanServer) { this.ebeanServer = ebeanServer; - for (int i = 0; i < propertiesMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { // used for creating lazy loading lists etc - propertiesMany[i].setLoader(ebeanServer); + aPropertiesMany.setLoader(ebeanServer); } } @@ -661,18 +662,18 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void initialiseOther(Map asOfTableMap, String asOfViewSuffix, Map draftTableMap) { - for (int i = 0; i < propertiesManyToMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesManyToMany1 : propertiesManyToMany) { // register associated draft table for M2M intersection - propertiesManyToMany[i].registerDraftIntersectionTable(draftTableMap); + aPropertiesManyToMany1.registerDraftIntersectionTable(draftTableMap); } if (historySupport) { // history support on this bean so check all associated intersection tables // and if they are not excluded register the associated 'with history' table - for (int i = 0; i < propertiesManyToMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesManyToMany : propertiesManyToMany) { // register associated history table for M2M intersection - if (!propertiesManyToMany[i].isExcludedFromHistory()) { - TableJoin intersectionTableJoin = propertiesManyToMany[i].getIntersectionTableJoin(); + if (!aPropertiesManyToMany.isExcludedFromHistory()) { + TableJoin intersectionTableJoin = aPropertiesManyToMany.getIntersectionTableJoin(); String intersectionTableName = intersectionTableJoin.getTable(); asOfTableMap.put(intersectionTableName, intersectionTableName + asOfViewSuffix); } @@ -716,8 +717,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ @SuppressWarnings("unchecked") public void initialiseDocMapping() { - for (int i = 0; i < propertiesMany.length; i++) { - propertiesMany[i].initialisePostTarget(); + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + aPropertiesMany.initialisePostTarget(); } if (inheritInfo != null && !inheritInfo.isRoot()) { docStoreAdapter = (DocStoreBeanAdapter) inheritInfo.getRoot().desc().docStoreAdapter(); @@ -835,8 +836,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < idList.size(); i++) { - idBinder.bindId(delete, idList.get(i)); + for (Object anIdList : idList) { + idBinder.bindId(delete, anIdList); } return delete; } @@ -851,8 +852,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { DefaultSqlUpdate sqlDelete = new DefaultSqlUpdate(baseSql); Object[] bindValues = idBinder.getBindValues(id); - for (int i = 0; i < bindValues.length; i++) { - sqlDelete.addParameter(bindValues[i]); + for (Object bindValue : bindValues) { + sqlDelete.addParameter(bindValue); } return sqlDelete; @@ -867,8 +868,10 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } public void initialiseFkeys() { - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].addFkey(); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + if (!aPropertiesOneImported.isFormula()) { + aPropertiesOneImported.addFkey(); + } } } @@ -974,12 +977,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { prop.docStoreMapping(mapping, prefix); } if (inheritInfo != null) { - inheritInfo.visitChildren(new InheritInfoVisitor() { - @Override - public void visit(InheritInfo inheritInfo) { - for (BeanProperty localProperty : inheritInfo.localProperties()) { - localProperty.docStoreMapping(mapping, prefix); - } + inheritInfo.visitChildren(inheritInfo1 -> { + for (BeanProperty localProperty : inheritInfo1.localProperties()) { + localProperty.docStoreMapping(mapping, prefix); } }); } @@ -1362,7 +1362,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } public List collectQueryPlanStatisticsInternal(boolean reset, boolean collectAll) { - List list = new ArrayList(queryPlanCache.size()); + List list = new ArrayList<>(queryPlanCache.size()); for (CQueryPlan queryPlan : queryPlanCache.values()) { Snapshot snapshot = queryPlan.getSnapshot(reset); if (collectAll || snapshot.getExecutionCount() > 0) { @@ -1472,9 +1472,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ private BeanProperty findWhenCreatedProperty() { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - if (propertiesBaseScalar[i].isGeneratedWhenCreated()) { - return propertiesBaseScalar[i]; + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + if (aPropertiesBaseScalar.isGeneratedWhenCreated()) { + return aPropertiesBaseScalar; } } return null; @@ -1485,9 +1485,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ private BeanProperty findWhenModifiedProperty() { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - if (propertiesBaseScalar[i].isGeneratedWhenModified()) { - return propertiesBaseScalar[i]; + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + if (aPropertiesBaseScalar.isGeneratedWhenModified()) { + return aPropertiesBaseScalar; } } return null; @@ -1499,9 +1499,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { public BeanPropertyAssocMany getManyProperty(SpiQuery query) { OrmQueryDetail detail = query.getDetail(); - for (int i = 0; i < propertiesMany.length; i++) { - if (detail.includesPath(propertiesMany[i].getName())) { - return propertiesMany[i]; + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + if (detail.includesPath(aPropertiesMany.getName())) { + return aPropertiesMany; } } @@ -1568,8 +1568,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Creates a new EntityBean. * The parameter isNew controls either this is a new bean (then * {@link BeanPostConstructListener#postCreate(Object)} will be invoked) or - * a reference (then {@link BeanPostLoad#postLoad(Object)} will be invoked - * on first access (lazy load) or immediately (eager load) + * a reference (then {@link BeanPostLoad#postLoad(Object)} will be invoked + * on first access (lazy load) or immediately (eager load) */ @SuppressWarnings("unchecked") public EntityBean createEntityBean(boolean isNew) { @@ -1580,12 +1580,12 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { beanPostConstructListener.autowire(bean); // calls all registered listeners beanPostConstructListener.postConstruct(bean); // calls first the @PostConstruct method and then the listeners } - + if (unloadProperties.length > 0) { // 'unload' any properties initialised in the default constructor EntityBeanIntercept ebi = bean._ebean_getIntercept(); - for (int i = 0; i < unloadProperties.length; i++) { - ebi.setPropertyUnloaded(unloadProperties[i]); + for (int unloadProperty : unloadProperties) { + ebi.setPropertyUnloaded(unloadProperty); } } if (beanPostConstructListener != null && isNew) { @@ -1598,7 +1598,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { throw new PersistenceException(ex); } } - + /** * Creates a new entitybean without invoking {@link BeanPostConstructListener#postCreate(Object)} */ @@ -1941,11 +1941,11 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { // load the List/Set/Map proxy objects (deferred fetching of lists) BeanPropertyAssocMany[] manys = propertiesMany(); - for (int i = 0; i < manys.length; i++) { - if (!ebi.isLoadedProperty(manys[i].getPropertyIndex())) { - BeanCollection ref = manys[i].createReferenceIfNull(bean); + for (BeanPropertyAssocMany many : manys) { + if (!ebi.isLoadedProperty(many.getPropertyIndex())) { + BeanCollection ref = many.createReferenceIfNull(bean); if (ref != null && !ref.isRegisteredWithLoadContext()) { - String path = SplitName.add(prefix, manys[i].getName()); + String path = SplitName.add(prefix, many.getName()); loadContext.register(path, ref); } } @@ -2014,7 +2014,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { comparators[i] = createPropertyComparator(sortProperty); } - return new ElComparatorCompound(comparators); + return new ElComparatorCompound<>(comparators); } private ElComparator createPropertyComparator(SortByClause.Property sortProp) { @@ -2025,7 +2025,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { if (nullsHigh == null) { nullsHigh = Boolean.TRUE; } - return new ElComparatorProperty(elGetValue, sortProp.isAscending(), nullsHigh); + return new ElComparatorProperty<>(elGetValue, sortProp.isAscending(), nullsHigh); } @Override @@ -2150,9 +2150,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { public void resetManyProperties(Object dbBean) { EntityBean bean = (EntityBean) dbBean; - for (int i = 0; i < propertiesMany.length; i++) { - if (propertiesMany[i].isCascadeRefresh()) { - propertiesMany[i].resetMany(bean); + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + if (aPropertiesMany.isCascadeRefresh()) { + aPropertiesMany.resetMany(bean); } } } @@ -2603,8 +2603,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Set the embedded owner on any embedded bean properties. */ public void setEmbeddedOwner(EntityBean bean) { - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].setEmbeddedOwner(bean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.setEmbeddedOwner(bean); } } @@ -2627,7 +2627,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } if (idProperty.isEmbedded()) { - // not using Id generator so just base on isLoaded() + // not using Id generator so just base on isLoaded() return !ebi.isLoaded(); } if (!hasIdValue(ebi.getOwner())) { @@ -2677,8 +2677,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Check for mutable scalar types and mark as dirty if necessary. */ public void checkMutableProperties(EntityBeanIntercept ebi) { - for (int i = 0; i < propertiesMutable.length; i++) { - BeanProperty beanProperty = propertiesMutable[i]; + for (BeanProperty beanProperty : propertiesMutable) { int propertyIndex = beanProperty.getPropertyIndex(); if (!ebi.isDirtyProperty(propertyIndex) && ebi.isLoadedProperty(propertyIndex)) { Object value = beanProperty.getValue(ebi.getOwner()); @@ -2719,7 +2718,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public Map diffForInsert(EntityBean newBean) { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); diffForInsert(null, map, newBean); return map; } @@ -2728,14 +2727,14 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Populate the diff for inserts with flattened non-null property values. */ public void diffForInsert(String prefix, Map map, EntityBean newBean) { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - propertiesBaseScalar[i].diffForInsert(prefix, map, newBean); + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + aPropertiesBaseScalar.diffForInsert(prefix, map, newBean); } - for (int i = 0; i < propertiesOne.length; i++) { - propertiesOne[i].diffForInsert(prefix, map, newBean); + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { + aPropertiesOne.diffForInsert(prefix, map, newBean); } - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].diffForInsert(prefix, map, newBean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.diffForInsert(prefix, map, newBean); } } @@ -2743,7 +2742,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Return the diff comparing the bean values. */ public Map diff(EntityBean newBean, EntityBean oldBean) { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); diff(null, map, newBean, oldBean); return map; } @@ -2753,14 +2752,14 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void diff(String prefix, Map map, EntityBean newBean, EntityBean oldBean) { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - propertiesBaseScalar[i].diff(prefix, map, newBean, oldBean); + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + aPropertiesBaseScalar.diff(prefix, map, newBean, oldBean); } - for (int i = 0; i < propertiesOne.length; i++) { - propertiesOne[i].diff(prefix, map, newBean, oldBean); + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { + aPropertiesOne.diff(prefix, map, newBean, oldBean); } - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].diff(prefix, map, newBean, oldBean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.diff(prefix, map, newBean, oldBean); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java index 3b9e066ed..888ad0d71 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java @@ -125,8 +125,8 @@ final class BeanDescriptorCacheHelp { * that does have bean caching enabled. */ private boolean isNotifyOnDeletes() { - for (int i = 0; i < propertiesOneImported.length; i++) { - if (propertiesOneImported[i].isCacheNotify()) { + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + if (aPropertiesOneImported.isCacheNotify()) { return true; } } @@ -264,8 +264,7 @@ final class BeanDescriptorCacheHelp { List idList = entry.getIdList(); bc.checkEmptyLazyLoad(); - for (int i = 0; i < idList.size(); i++) { - Object id = idList.get(i); + for (Object id : idList) { Object refBean = targetDescriptor.createReference(readOnly, false, id, persistenceContext); many.add(bc, (EntityBean) refBean); } @@ -296,7 +295,7 @@ final class BeanDescriptorCacheHelp { BeanDescriptor targetDescriptor = many.getTargetDescriptor(); - List idList = new ArrayList(); + List idList = new ArrayList<>(); Collection actualDetails = BeanCollectionUtil.getActualEntries(details); if (actualDetails == null) { return null; @@ -320,7 +319,7 @@ final class BeanDescriptorCacheHelp { // check if it is a find by unique id (using the natural key) NaturalKeyBindParam keyBindParam = query.getNaturalKeyBindParam(); if (keyBindParam == null || !isNaturalKey(keyBindParam.getName())) { - // query is not appropriate + // query is not appropriate return null; } @@ -545,8 +544,8 @@ final class BeanDescriptorCacheHelp { } beanCache.remove(id); } - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].cacheClear(); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + aPropertiesOneImported.cacheClear(); } } @@ -608,8 +607,8 @@ final class BeanDescriptorCacheHelp { } private void cacheDeleteImported(boolean clear, EntityBean entityBean, CacheChangeSet changeSet) { - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].cacheDelete(clear, entityBean, changeSet); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + aPropertiesOneImported.cacheDelete(clear, entityBean, changeSet); } } @@ -627,8 +626,7 @@ final class BeanDescriptorCacheHelp { List> manyCollections = updateRequest.getUpdatedManyCollections(); if (manyCollections != null) { - for (int i = 0; i < manyCollections.size(); i++) { - BeanPropertyAssocMany many = manyCollections.get(i); + for (BeanPropertyAssocMany many : manyCollections) { Object details = many.getValue(updateRequest.getEntityBean()); CachedManyIds entry = createManyIds(many, details); if (entry != null) { @@ -642,7 +640,7 @@ final class BeanDescriptorCacheHelp { boolean updateNaturalKey = false; - Map changes = new LinkedHashMap(); + Map changes = new LinkedHashMap<>(); EntityBean bean = updateRequest.getEntityBean(); boolean[] dirtyProperties = updateRequest.getDirtyProperties(); for (int i = 0; i < dirtyProperties.length; i++) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java index 6fcc8319c..70f35ec56 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java @@ -30,7 +30,7 @@ public final class BeanDescriptorDraftHelp { */ private BeanProperty[] resetProperties() { - List list = new ArrayList(); + List list = new ArrayList<>(); BeanProperty[] props = desc.propertiesNonMany(); for (BeanProperty prop : props) { @@ -69,6 +69,7 @@ public final class BeanDescriptorDraftHelp { * This will recursive transfer values to all @DraftableElement properties. *

*/ + @SuppressWarnings("unchecked") public T publish(T draftBean, T liveBean) { if (liveBean == null) { @@ -84,14 +85,14 @@ public final class BeanDescriptorDraftHelp { } BeanProperty[] props = desc.propertiesNonMany(); - for (int i = 0; i < props.length; i++) { - props[i].publish(draft, live); + for (BeanProperty prop : props) { + prop.publish(draft, live); } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - if (many[i].getTargetDescriptor().isDraftable()) { - many[i].publishMany(draft, live); + for (BeanPropertyAssocMany aMany : many) { + if (aMany.getTargetDescriptor().isDraftable()) { + aMany.publishMany(draft, live); } } @@ -104,16 +105,16 @@ public final class BeanDescriptorDraftHelp { public void draftQueryOptimise(Query query) { BeanPropertyAssocOne[] one = desc.propertiesOne(); - for (int i = 0; i < one.length; i++) { - if (one[i].getTargetDescriptor().isDraftableElement()) { - query.fetch(one[i].getName()); + for (BeanPropertyAssocOne anOne : one) { + if (anOne.getTargetDescriptor().isDraftableElement()) { + query.fetch(anOne.getName()); } } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - if (many[i].getTargetDescriptor().isDraftableElement()) { - query.fetch(many[i].getName()); + for (BeanPropertyAssocMany aMany : many) { + if (aMany.getTargetDescriptor().isDraftableElement()) { + query.fetch(aMany.getName()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java index cf220a3c8..6dbf2e357 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java @@ -63,9 +63,9 @@ public class BeanDescriptorJsonHelp { writeJson.writeStartObject(null); // render the dirty properties BeanProperty[] props = desc.propertiesNonTransient(); - for (int j = 0; j < props.length; j++) { - if (dirtyProps[props[j].getPropertyIndex()]) { - props[j].jsonWrite(writeJson, bean); + for (BeanProperty prop : props) { + if (dirtyProps[prop.getPropertyIndex()]) { + prop.jsonWrite(writeJson, bean); } } writeJson.writeEndObject(); @@ -103,7 +103,7 @@ public class BeanDescriptorJsonHelp { String propName = parser.getCurrentName(); if (!propName.equalsIgnoreCase(discColumn)) { - // just try to assume this is the correct bean type in the inheritance + // just try to assume this is the correct bean type in the inheritance BeanProperty property = desc.getBeanProperty(propName); if (property != null) { EntityBean bean = desc.createEntityBean(); @@ -145,7 +145,7 @@ public class BeanDescriptorJsonHelp { } else { // read an unmapped property if (unmappedProperties == null) { - unmappedProperties = new LinkedHashMap(); + unmappedProperties = new LinkedHashMap<>(); } unmappedProperties.put(key, EJson.parse(parser)); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java index ab4ef1c81..a153569ba 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -138,19 +138,19 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private final String serverName; - private Map, DeployBeanInfo> deployInfoMap = new HashMap, DeployBeanInfo>(); + private Map, DeployBeanInfo> deployInfoMap = new HashMap<>(); - private final Map, BeanTable> beanTableMap = new HashMap, BeanTable>(); + private final Map, BeanTable> beanTableMap = new HashMap<>(); - private final Map> descMap = new HashMap>(); + private final Map> descMap = new HashMap<>(); - private final Map> descQueueMap = new HashMap>(); + private final Map> descQueueMap = new HashMap<>(); - private final Map> beanManagerMap = new HashMap>(); + private final Map> beanManagerMap = new HashMap<>(); - private final Map>> tableToDescMap = new HashMap>>(); + private final Map>> tableToDescMap = new HashMap<>(); - private final Map>> tableToViewDescMap = new HashMap>>(); + private final Map>> tableToViewDescMap = new HashMap<>(); private List> immutableDescriptorList; @@ -179,12 +179,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap { /** * Map of base tables to 'with history views' used to support 'as of' queries. */ - private final Map asOfTableMap = new HashMap(); + private final Map asOfTableMap = new HashMap<>(); /** * Map of base tables to 'draft' tables. */ - private final Map draftTableMap = new HashMap(); + private final Map draftTableMap = new HashMap<>(); /** * Create for a given database dbConfig. @@ -324,7 +324,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { // creates the BeanDescriptors readEntityRelationships(); - List> list = new ArrayList>(descMap.values()); + List> list = new ArrayList<>(descMap.values()); Collections.sort(list, beanDescComparator); immutableDescriptorList = Collections.unmodifiableList(list); @@ -353,7 +353,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { Enumeration resources = classLoader.getResources("ebean.xml"); - List mappings = new ArrayList(); + List mappings = new ArrayList<>(); while (resources.hasMoreElements()) { URL url = resources.nextElement(); InputStream is = url.openStream(); @@ -423,15 +423,15 @@ public class BeanDescriptorManager implements BeanDescriptorMap { List> normalBeanTypes = tableToDescMap.get(tableName); if (normalBeanTypes != null) { // 'normal' entity beans based on a "base table" - for (int i = 0; i < normalBeanTypes.size(); i++) { - normalBeanTypes.get(i).cacheHandleBulkUpdate(tableIUD); + for (BeanDescriptor normalBeanType : normalBeanTypes) { + normalBeanType.cacheHandleBulkUpdate(tableIUD); } } List> viewBeans = tableToViewDescMap.get(tableName); if (viewBeans != null) { // entity beans based on a "view" - for (int i = 0; i < viewBeans.size(); i++) { - viewBeans.get(i).cacheHandleBulkUpdate(tableIUD); + for (BeanDescriptor viewBean : viewBeans) { + viewBean.cacheHandleBulkUpdate(tableIUD); } } } @@ -458,8 +458,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { for (String depTable : viewInvalidation) { List> list = tableToViewDescMap.get(depTable.toLowerCase()); if (list != null) { - for (int i = 0; i < list.size(); i++) { - list.get(i).queryCacheClear(); + for (BeanDescriptor aList : list) { + aList.queryCacheClear(); } } } @@ -479,7 +479,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { baseTable = baseTable.toLowerCase(); List> list = tableToDescMap.get(baseTable); if (list == null) { - list = new ArrayList>(1); + list = new ArrayList<>(1); tableToDescMap.put(baseTable, list); } list.add(desc); @@ -493,7 +493,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { depTable = depTable.toLowerCase(); List> list = tableToViewDescMap.get(depTable); if (list == null) { - list = new ArrayList>(1); + list = new ArrayList<>(1); tableToViewDescMap.put(depTable, list); } list.add(desc); @@ -639,12 +639,13 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private BeanDescriptor createEmbedded(Class beanClass) { DeployBeanInfo info = getDeploy(beanClass); - return new BeanDescriptor(this, info.getDescriptor()); + return new BeanDescriptor<>(this, info.getDescriptor()); } /** * Return the bean deploy info for the given class. */ + @SuppressWarnings("unchecked") public DeployBeanInfo getDeploy(Class cls) { return (DeployBeanInfo) deployInfoMap.get(cls); } @@ -662,8 +663,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private void readEmbeddedDeployment() { List> embeddedClasses = bootupClasses.getEmbeddables(); - for (int i = 0; i < embeddedClasses.size(); i++) { - registerBeanDescriptor(createEmbedded(embeddedClasses.get(i))); + for (Class embeddedClass : embeddedClasses) { + registerBeanDescriptor(createEmbedded(embeddedClass)); } } @@ -858,7 +859,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { // this is the entity bean type - that owns this property Class owningType = prop.getOwningType(); - Set matchSet = new HashSet(); + Set matchSet = new HashSet<>(); // get the bean descriptor that holds the mappedBy property DeployBeanDescriptor targetDesc = getTargetDescriptor(prop); @@ -1165,7 +1166,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { */ private DeployBeanInfo createDeployBeanInfo(Class beanClass) { - DeployBeanDescriptor desc = new DeployBeanDescriptor(this, beanClass, serverConfig); + DeployBeanDescriptor desc = new DeployBeanDescriptor<>(this, beanClass, serverConfig); desc.setUpdateChangesOnly(updateChangesOnly); @@ -1178,7 +1179,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { createProperties.createProperties(desc); - DeployBeanInfo info = new DeployBeanInfo(deployUtil, desc); + DeployBeanInfo info = new DeployBeanInfo<>(deployUtil, desc); readAnnotations.readInitial(info, eagerFetchLobs); return info; @@ -1394,8 +1395,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { boolean hasVersionProperty = false; List props = desc.propertiesBase(); - for (int i = 0; i < props.size(); i++) { - if (props.get(i).isVersionColumn()) { + for (DeployBeanProperty prop : props) { + if (prop.isVersionColumn()) { hasVersionProperty = true; } } @@ -1406,8 +1407,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private boolean hasEntityBeanInterface(Class beanClass) { Class[] interfaces = beanClass.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - if (interfaces[i].equals(EntityBean.class)) { + for (Class anInterface : interfaces) { + if (anInterface.equals(EntityBean.class)) { return true; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java index a50bd8fe3..c3b65060f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java @@ -30,8 +30,7 @@ public class BeanFinderManager { */ public void addFindControllers(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanFindController c = list.get(i); + for (BeanFindController c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanFindController on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.setBeanFinder(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java index 19e782aab..1bc6c474e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java @@ -64,14 +64,14 @@ public class BeanLifecycleAdapterFactory { private static class MethodsHolder { private boolean hasPersistMethods; - private final List preInserts = new ArrayList(); - private final List postInserts = new ArrayList(); - private final List preUpdates = new ArrayList(); - private final List postUpdates = new ArrayList(); - private final List preDeletes = new ArrayList(); - private final List postDeletes = new ArrayList(); - private final List postLoads = new ArrayList(); - private final List postConstructs = new ArrayList(); + private final List preInserts = new ArrayList<>(); + private final List postInserts = new ArrayList<>(); + private final List preUpdates = new ArrayList<>(); + private final List postUpdates = new ArrayList<>(); + private final List preDeletes = new ArrayList<>(); + private final List postDeletes = new ArrayList<>(); + private final List postLoads = new ArrayList<>(); + private final List postConstructs = new ArrayList<>(); /** * Has one of the pre or post insert update delete annotated methods. @@ -170,16 +170,14 @@ public class BeanLifecycleAdapterFactory { private void invoke(Method method, Object bean) { try { method.invoke(bean); - } catch (InvocationTargetException e) { - throw new PersistenceException("Error invoking lifecycle method", e); - } catch (IllegalAccessException e) { + } catch (InvocationTargetException | IllegalAccessException e) { throw new PersistenceException("Error invoking lifecycle method", e); } } private void invoke(Method[] methods, BeanPersistRequest request) { - for (int i = 0; i < methods.length; i++) { - invoke(methods[i], request.getBean()); + for (Method method : methods) { + invoke(method, request.getBean()); } } @@ -237,21 +235,19 @@ public class BeanLifecycleAdapterFactory { private void invoke(Method method, Object bean) { try { method.invoke(bean); - } catch (InvocationTargetException e) { - throw new PersistenceException("Error invoking lifecycle method", e); - } catch (IllegalAccessException e) { + } catch (InvocationTargetException | IllegalAccessException e) { throw new PersistenceException("Error invoking lifecycle method", e); } } @Override public void postLoad(Object bean) { - for (int i = 0; i < postLoadMethods.length; i++) { - invoke(postLoadMethods[i], bean); + for (Method postLoadMethod : postLoadMethods) { + invoke(postLoadMethod, bean); } } } - + /** * PostConstructAdapter using reflection to invoke lifecycle methods. */ @@ -272,17 +268,15 @@ public class BeanLifecycleAdapterFactory { private void invoke(Method method, Object bean) { try { method.invoke(bean); - } catch (InvocationTargetException e) { - throw new PersistenceException("Error invoking lifecycle method", e); - } catch (IllegalAccessException e) { + } catch (InvocationTargetException | IllegalAccessException e) { throw new PersistenceException("Error invoking lifecycle method", e); } } @Override public void postConstruct(Object bean) { - for (int i = 0; i < postConstructMethods.length; i++) { - invoke(postConstructMethods[i], bean); + for (Method postConstructMethod : postConstructMethods) { + invoke(postConstructMethod, bean); } } @@ -290,7 +284,7 @@ public class BeanLifecycleAdapterFactory { public void autowire(Object bean) { // autowire is done by global PostConstructListener only } - + @Override public void postCreate(Object bean) { // postCreate is done by global PostConstructListener only diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java index c44ee4e56..8745568f2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java @@ -61,7 +61,7 @@ public final class BeanListHelp implements BeanCollectionHelp { BeanList bl = (BeanList) bc; if (bl.getActualList() == null) { - bl.setActualList(new ArrayList()); + bl.setActualList(new ArrayList<>()); } return bl; @@ -72,12 +72,12 @@ public final class BeanListHelp implements BeanCollectionHelp { @Override public BeanCollection createEmptyNoParent() { - return new BeanList(); + return new BeanList<>(); } @Override public BeanCollection createEmpty(EntityBean parentBean) { - BeanList beanList = new BeanList(loader, parentBean, propertyName); + BeanList beanList = new BeanList<>(loader, parentBean, propertyName); if (many != null) { beanList.setModifyListening(many.getModifyListenMode()); } @@ -87,7 +87,7 @@ public final class BeanListHelp implements BeanCollectionHelp { @Override public BeanCollection createReference(EntityBean parentBean) { - BeanList beanList = new BeanList(loader, parentBean, propertyName); + BeanList beanList = new BeanList<>(loader, parentBean, propertyName); beanList.setModifyListening(many.getModifyListenMode()); return beanList; } @@ -146,8 +146,8 @@ public final class BeanListHelp implements BeanCollectionHelp { if (!list.isEmpty() || ctx.isIncludeEmpty()) { ctx.beginAssocMany(name); - for (int j = 0; j < list.size(); j++) { - targetDescriptor.jsonWrite(ctx, (EntityBean) list.get(j)); + for (Object aList : list) { + targetDescriptor.jsonWrite(ctx, (EntityBean) aList); } ctx.endAssocMany(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanManagerFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanManagerFactory.java index ff9bb39bb..70723d72d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanManagerFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanManagerFactory.java @@ -17,7 +17,7 @@ public class BeanManagerFactory { public BeanManager create(BeanDescriptor desc) { - return new BeanManager(desc, persisterFactory.create(desc)); + return new BeanManager<>(desc, persisterFactory.create(desc)); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java index 9b31e7556..8e7971647 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java @@ -64,7 +64,7 @@ public final class BeanMapHelp implements BeanCollectionHelp { BeanMap bm = (BeanMap) bc; Map actualMap = bm.getActualMap(); if (actualMap == null) { - actualMap = new LinkedHashMap(); + actualMap = new LinkedHashMap<>(); bm.setActualMap(actualMap); } return new Adder(beanProp, actualMap); @@ -92,16 +92,14 @@ public final class BeanMapHelp implements BeanCollectionHelp { } @Override - @SuppressWarnings("unchecked") public BeanCollection createEmptyNoParent() { - return new BeanMap(); + return new BeanMap<>(); } @Override - @SuppressWarnings("unchecked") public BeanCollection createEmpty(EntityBean ownerBean) { - BeanMap beanMap = new BeanMap(loader, ownerBean, propertyName); + BeanMap beanMap = new BeanMap<>(loader, ownerBean, propertyName); if (many != null) { beanMap.setModifyListening(many.getModifyListenMode()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanProperty.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanProperty.java index ac1619718..91be1e4d8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanProperty.java @@ -1386,22 +1386,17 @@ public class BeanProperty implements ElPropertyValue, Property { public void docStoreMapping(DocMappingBuilder mapping, String prefix) { if (mapping.includesProperty(prefix, name)) { - DocPropertyType type = scalarType.getDocType(); DocPropertyOptions options = docOptions.copy(); - if (DocPropertyType.UUID == type || DocPropertyType.ENUM == type || isStringId(type)) { - options.setCode(true); + if (isKeywordType(type, options)) { + type = DocPropertyType.KEYWORD; } - mapping.add(new DocPropertyMapping(name, type, options)); } } - /** - * Return true if this is a String Id property and should be treated as a code by the document store. - */ - private boolean isStringId(DocPropertyType type) { - return DocPropertyType.STRING == type && (id || discriminator); + private boolean isKeywordType(DocPropertyType type, DocPropertyOptions docOptions) { + return type == DocPropertyType.TEXT && (docOptions.isCode() || id || discriminator); } public void merge(EntityBean bean, EntityBean existing) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java index b9bc0bd92..f41e5839d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -330,7 +330,7 @@ public abstract class BeanPropertyAssoc extends BeanProperty { if (descriptor.isRawSqlBased()) { String dbColumn = owner.getDbColumn(); - return new ImportedIdSimple(owner, dbColumn, idProp, 0); + return new ImportedIdSimple(owner, dbColumn, null, idProp, 0); } TableJoinColumn[] cols = join.columns(); @@ -360,10 +360,10 @@ public abstract class BeanPropertyAssoc extends BeanProperty { private ImportedIdSimple[] createImportedList(BeanPropertyAssoc owner, TableJoinColumn[] cols, BeanProperty[] props, BeanProperty[] others) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); - for (int i = 0; i < cols.length; i++) { - list.add(createImportedScalar(owner, cols[i], props, others)); + for (TableJoinColumn col : cols) { + list.add(createImportedScalar(owner, col, props, others)); } return ImportedIdSimple.sort(list); @@ -373,16 +373,17 @@ public abstract class BeanPropertyAssoc extends BeanProperty { String matchColumn = col.getForeignDbColumn(); String localColumn = col.getLocalDbColumn(); + String localSqlFormula = col.getLocalSqlFormula(); for (int j = 0; j < props.length; j++) { if (props[j].getDbColumn().equalsIgnoreCase(matchColumn)) { - return new ImportedIdSimple(owner, localColumn, props[j], j); + return new ImportedIdSimple(owner, localColumn, localSqlFormula, props[j], j); } } for (int j = 0; j < others.length; j++) { if (others[j].getDbColumn().equalsIgnoreCase(matchColumn)) { - return new ImportedIdSimple(owner, localColumn, others[j], j + props.length); + return new ImportedIdSimple(owner, localColumn, localSqlFormula, others[j], j + props.length); } } @@ -399,8 +400,8 @@ public abstract class BeanPropertyAssoc extends BeanProperty { } else { EntityBean parent = (EntityBean) parentId; - for (int i = 0; i < exportedProperties.length; i++) { - Object embVal = exportedProperties[i].getValue(parent); + for (ExportedProperty exportedProperty : exportedProperties) { + Object embVal = exportedProperty.getValue(parent); bindValues.add(embVal); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index a64586646..1ef618e42 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -305,7 +305,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { private List findIdsByParentId(Object parentId, Transaction t, ArrayList excludeDetailIds) { String rawWhere = deriveWhereParentIdSql(false, ""); - List bindValues = new ArrayList(); + List bindValues = new ArrayList<>(); bindWhereParentId(bindValues, parentId); EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -375,9 +375,9 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { String expr = rawWhere + inClause; - List bindValues = new ArrayList(); - for (int i = 0; i < parentIdList.size(); i++) { - bindWhereParentId(bindValues, parentIdList.get(i)); + List bindValues = new ArrayList<>(); + for (Object aParentIdList : parentIdList) { + bindWhereParentId(bindValues, aParentIdList); } EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -403,8 +403,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < parentIdist.size(); i++) { - bindWhereParendId(delete, parentIdist.get(i)); + for (Object aParentIdist : parentIdist) { + bindWhereParendId(delete, aParentIdist); } return delete; @@ -667,11 +667,11 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { if (exportedProperties.length == 1) { return parentIds; } - List expandedList = new ArrayList(parentIds.size() * exportedProperties.length); - for (int i = 0; i < parentIds.size(); i++) { - for (int y = 0; y < exportedProperties.length; y++) { - Object compId = parentIds.get(i); - expandedList.add(exportedProperties[y].getValue((EntityBean) compId)); + List expandedList = new ArrayList<>(parentIds.size() * exportedProperties.length); + for (Object parentId : parentIds) { + for (ExportedProperty exportedProperty : exportedProperties) { + Object compId = parentId; + expandedList.add(exportedProperty.getValue((EntityBean) compId)); } } return expandedList; @@ -684,8 +684,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { return; } EntityBean parent = (EntityBean) parentId; - for (int i = 0; i < exportedProperties.length; i++) { - Object embVal = exportedProperties[i].getValue(parent); + for (ExportedProperty exportedProperty : exportedProperties) { + Object embVal = exportedProperty.getValue(parent); sqlUpd.addParameter(embVal); } } @@ -696,8 +696,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { if (alias == null) { alias = "t0"; } - for (int i = 0; i < exportedProperties.length; i++) { - ctx.appendColumn(alias, exportedProperties[i].getForeignDbColumn()); + for (ExportedProperty exportedProperty : exportedProperties) { + ctx.appendColumn(alias, exportedProperty.getForeignDbColumn()); } } @@ -771,7 +771,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanProperty idProp = descriptor.getIdProperty(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); if (idProp != null && idProp.isEmbedded()) { @@ -779,8 +779,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanDescriptor targetDesc = one.getTargetDescriptor(); BeanProperty[] emIds = targetDesc.propertiesBaseScalar(); try { - for (int i = 0; i < emIds.length; i++) { - ExportedProperty expProp = findMatch(true, emIds[i]); + for (BeanProperty emId : emIds) { + ExportedProperty expProp = findMatch(true, emId); list.add(expProp); } } catch (PersistenceException e) { @@ -816,11 +816,11 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { columns = tableJoin.columns(); searchTable = tableJoin.getTable(); } - for (int i = 0; i < columns.length; i++) { - String matchTo = columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String matchTo = column.getLocalDbColumn(); if (matchColumn.equalsIgnoreCase(matchTo)) { - String foreignCol = columns[i].getForeignDbColumn(); + String foreignCol = column.getForeignDbColumn(); return new ExportedProperty(embedded, foreignCol, prop); } } @@ -849,8 +849,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanDescriptor targetDesc = getTargetDescriptor(); BeanPropertyAssocOne[] ones = targetDesc.propertiesOne(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; + for (BeanPropertyAssocOne prop : ones) { if (mappedBy != null) { // match using mappedBy as property name if (mappedBy.equalsIgnoreCase(prop.getName())) { @@ -935,9 +934,9 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanProperty idProp = descriptor.getIdProperty(); parentBean = (EntityBean) idProp.getValue(parentBean); } - for (int i = 0; i < exportedProperties.length; i++) { - Object val = exportedProperties[i].getValue(parentBean); - String fkColumn = exportedProperties[i].getForeignDbColumn(); + for (ExportedProperty exportedProperty : exportedProperties) { + Object val = exportedProperty.getValue(parentBean); + String fkColumn = exportedProperty.getForeignDbColumn(); row.put(fkColumn, val); } @@ -1032,11 +1031,12 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { } } + @SuppressWarnings("unchecked") private Map liveBeansAsMap(BeanCollection liveVal) { liveVal.size(); Collection liveBeans = liveVal.getActualDetails(); - Map liveMap = new LinkedHashMap(); + Map liveMap = new LinkedHashMap<>(); for (Object liveBean : liveBeans) { Object id = targetDescriptor.getId((EntityBean) liveBean); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java index 20b2f56b2..ef723bd65 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java @@ -78,9 +78,9 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { // Overriding of the columns and use table alias of owning BeanDescriptor BeanEmbeddedMeta overrideMeta = BeanEmbeddedMetaFactory.create(owner, deploy); embeddedProps = overrideMeta.getProperties(); - embeddedPropsMap = new HashMap(); - for (int i = 0; i < embeddedProps.length; i++) { - embeddedPropsMap.put(embeddedProps[i].getName(), embeddedProps[i]); + embeddedPropsMap = new HashMap<>(); + for (BeanProperty embeddedProp : embeddedProps) { + embeddedPropsMap.put(embeddedProp.getName(), embeddedProp); } } else { @@ -208,8 +208,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < parentIdist.size(); i++) { - targetIdBinder.bindId(delete, parentIdist.get(i)); + for (Object aParentIdist : parentIdist) { + targetIdBinder.bindId(delete, aParentIdist); } return delete; @@ -238,7 +238,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String rawWhere = deriveWhereParentIdSql(false); - List bindValues = new ArrayList(); + List bindValues = new ArrayList<>(); bindWhereParentId(bindValues, parentId); EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -257,9 +257,9 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String expr = rawWhere + inClause; - List bindValues = new ArrayList(); - for (int i = 0; i < parentIdList.size(); i++) { - bindWhereParentId(bindValues, parentIdList.get(i)); + List bindValues = new ArrayList<>(); + for (Object aParentIdList : parentIdList) { + bindWhereParentId(bindValues, aParentIdList); } EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -301,8 +301,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { targetIdBinder.buildRawSqlSelectChain(prefix, selectChain); } else { - for (int i = 0; i < embeddedProps.length; i++) { - embeddedProps[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty embeddedProp : embeddedProps) { + embeddedProp.buildRawSqlSelectChain(prefix, selectChain); } } } @@ -506,7 +506,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { BeanProperty idProp = descriptor.getIdProperty(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); if (idProp != null && idProp.isEmbedded()) { @@ -514,8 +514,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { BeanDescriptor targetDesc = one.getTargetDescriptor(); BeanProperty[] emIds = targetDesc.propertiesBaseScalar(); try { - for (int i = 0; i < emIds.length; i++) { - ExportedProperty expProp = findMatch(true, emIds[i]); + for (BeanProperty emId : emIds) { + ExportedProperty expProp = findMatch(true, emId); list.add(expProp); } } catch (PersistenceException e) { @@ -543,11 +543,11 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String searchTable = tableJoin.getTable(); TableJoinColumn[] columns = tableJoin.columns(); - for (int i = 0; i < columns.length; i++) { - String matchTo = columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String matchTo = column.getLocalDbColumn(); if (matchColumn.equalsIgnoreCase(matchTo)) { - String foreignCol = columns[i].getForeignDbColumn(); + String foreignCol = column.getForeignDbColumn(); return new ExportedProperty(embeddedProp, foreignCol, prop); } } @@ -570,6 +570,9 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { public void appendFrom(DbSqlContext ctx, SqlJoinType joinType) { if (!isTransient) { localHelp.appendFrom(ctx, joinType); + if (sqlFormulaJoin != null) { + ctx.appendFormulaJoin(sqlFormulaJoin, joinType); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java index 39a22f58e..57ff681c2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java @@ -31,9 +31,9 @@ public class BeanPropertyCompound extends BeanProperty { private final BeanProperty[] scalarProperties; - private final LinkedHashMap propertyMap = new LinkedHashMap(); + private final LinkedHashMap propertyMap = new LinkedHashMap<>(); - private final LinkedHashMap nonScalarMap = new LinkedHashMap(); + private final LinkedHashMap nonScalarMap = new LinkedHashMap<>(); /** * Create the property. @@ -46,14 +46,13 @@ public class BeanPropertyCompound extends BeanProperty { BeanPropertyCompoundRoot root = deploy.getFlatProperties(); this.scalarProperties = root.getScalarProperties(); - for (int i = 0; i < scalarProperties.length; i++) { - propertyMap.put(scalarProperties[i].getName(), scalarProperties[i]); + for (BeanProperty scalarProperty : scalarProperties) { + propertyMap.put(scalarProperty.getName(), scalarProperty); } List nonScalarPropsList = root.getNonScalarProperties(); - for (int i = 0; i < nonScalarPropsList.size(); i++) { - CtCompoundProperty ctProp = nonScalarPropsList.get(i); + for (CtCompoundProperty ctProp : nonScalarPropsList) { CtCompoundPropertyElAdapter adapter = new CtCompoundPropertyElAdapter(ctProp); nonScalarMap.put(ctProp.getRelativeName(), adapter); } @@ -102,8 +101,8 @@ public class BeanPropertyCompound extends BeanProperty { @Override public void appendSelect(DbSqlContext ctx, boolean subQuery) { if (!isTransient) { - for (int i = 0; i < scalarProperties.length; i++) { - scalarProperties[i].appendSelect(ctx, subQuery); + for (BeanProperty scalarProperty : scalarProperties) { + scalarProperty.appendSelect(ctx, subQuery); } } } @@ -125,10 +124,8 @@ public class BeanPropertyCompound extends BeanProperty { * Read the data from the resultSet effectively ignoring it and returning * null. */ - @SuppressWarnings("unchecked") @Override public Object read(DbReadContext ctx) throws SQLException { - return compoundType.read(ctx.getDataReader()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundRoot.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundRoot.java index e4e692ce4..8e9f9969e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundRoot.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundRoot.java @@ -31,7 +31,7 @@ public class BeanPropertyCompoundRoot { this.fullBeanName = deploy.getFullBeanName(); this.name = deploy.getName(); this.setter = deploy.getSetter(); - this.propList = new ArrayList(); + this.propList = new ArrayList<>(); } public BeanProperty[] getScalarProperties() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundScalar.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundScalar.java index 902dad24b..3df6100df 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundScalar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundScalar.java @@ -23,12 +23,10 @@ public class BeanPropertyCompoundScalar extends BeanProperty { /** * Return one of the scalar values from a compound type. */ - @SuppressWarnings("unchecked") public Object getValueObject(Object compoundValue) { return ctProperty.getValue(compoundValue); } - @SuppressWarnings("unchecked") @Override public Object getValue(EntityBean valueObject) { return ctProperty.getValue(valueObject); @@ -39,7 +37,6 @@ public class BeanPropertyCompoundScalar extends BeanProperty { setValueInCompound(bean, value, false); } - @SuppressWarnings("unchecked") public void setValueInCompound(EntityBean bean, Object value, boolean intercept) { Object compoundValue = ctProperty.setValue(bean, value); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java index b936781c1..4b54c62c9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java @@ -31,8 +31,7 @@ public class BeanQueryAdapterManager { */ public void addQueryAdapter(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanQueryAdapter c = list.get(i); + for (BeanQueryAdapter c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanQueryAdapter on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addQueryAdapter(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java index b1f88c4db..487d89f7e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java @@ -52,7 +52,7 @@ public final class BeanSetHelp implements BeanCollectionHelp { if (bc instanceof BeanSet) { BeanSet beanSet = (BeanSet) bc; if (beanSet.getActualSet() == null) { - beanSet.setActualSet(new LinkedHashSet()); + beanSet.setActualSet(new LinkedHashSet<>()); } return beanSet; @@ -70,14 +70,13 @@ public final class BeanSetHelp implements BeanCollectionHelp { } @Override - @SuppressWarnings("unchecked") public BeanCollection createEmptyNoParent() { - return new BeanSet(); + return new BeanSet<>(); } @Override public BeanCollection createEmpty(EntityBean ownerBean) { - BeanSet beanSet = new BeanSet(loader, ownerBean, propertyName); + BeanSet beanSet = new BeanSet<>(loader, ownerBean, propertyName); if (many != null) { beanSet.setModifyListening(many.getModifyListenMode()); } @@ -87,7 +86,7 @@ public final class BeanSetHelp implements BeanCollectionHelp { @Override public BeanCollection createReference(EntityBean parentBean) { - BeanSet beanSet = new BeanSet(loader, parentBean, propertyName); + BeanSet beanSet = new BeanSet<>(loader, parentBean, propertyName); beanSet.setModifyListening(many.getModifyListenMode()); return beanSet; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java index f52116158..b19123965 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java @@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory; public class BeanTable { private static final Logger logger = LoggerFactory.getLogger(BeanTable.class); - + private final Class beanType; /** @@ -29,7 +29,7 @@ public class BeanTable { private final String baseTable; private final BeanProperty[] idProperties; - + /** * Create the BeanTable. */ @@ -38,11 +38,11 @@ public class BeanTable { this.baseTable = InternString.intern(mutable.getBaseTable()); this.idProperties = mutable.createIdProperties(owner); } - + public String toString(){ - return baseTable; + return baseTable; } - + /** * Return the base table for this BeanTable. * This is used to determine the join information @@ -51,17 +51,17 @@ public class BeanTable { public String getBaseTable() { return baseTable; } - + /** * Gets the unqualified base table. - * + * * @return the unqualified base table */ public String getUnqualifiedBaseTable(){ final String[] chunks = baseTable.split("\\."); return chunks.length == 2 ? chunks[1] :chunks[0]; } - + /** * Return the Id properties. */ @@ -75,12 +75,12 @@ public class BeanTable { public Class getBeanType() { return beanType; } - - public void createJoinColumn(String foreignKeyPrefix, DeployTableJoin join, boolean reverse) { - + + public void createJoinColumn(String foreignKeyPrefix, DeployTableJoin join, boolean reverse, String sqlFormulaSelect) { + boolean complexKey = false; BeanProperty[] props = idProperties; - + if (idProperties.length == 1){ if (idProperties[0] instanceof BeanPropertyAssocOne) { BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne)idProperties[0]; @@ -88,30 +88,34 @@ public class BeanTable { complexKey = true; } } - - for (int i = 0; i < props.length; i++) { - - String lc = props[i].getDbColumn(); - String fk = lc; - if (foreignKeyPrefix != null){ - fk = foreignKeyPrefix+"_"+fk; - } - - if (complexKey){ - // just to copy the column name rather than prefix with the foreignKeyPrefix. - // I think that with complex keys this is the more common approach. - String msg = "On table["+baseTable+"] foreign key column ["+lc+"]"; - logger.debug(msg); - fk = lc; - } - - DeployTableJoinColumn joinCol = new DeployTableJoinColumn(lc, fk); - if (reverse){ - joinCol = joinCol.reverse(); - } - join.addJoinColumn(joinCol); - } - + + for (BeanProperty prop : props) { + + String lc = prop.getDbColumn(); + String fk = lc; + if (foreignKeyPrefix != null) { + fk = foreignKeyPrefix + "_" + fk; + } + + if (complexKey) { + // just to copy the column name rather than prefix with the foreignKeyPrefix. + // I think that with complex keys this is the more common approach. + String msg = "On table[" + baseTable + "] foreign key column [" + lc + "]"; + logger.debug(msg); + fk = lc; + } + if (sqlFormulaSelect != null) { + fk = sqlFormulaSelect; + } + + DeployTableJoinColumn joinCol = new DeployTableJoinColumn(lc, fk); + joinCol.setForeignSqlFormula(sqlFormulaSelect); + if (reverse) { + joinCol = joinCol.reverse(); + } + join.addJoinColumn(joinCol); + } + } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java index 06f3218fa..941f59023 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java @@ -16,28 +16,28 @@ import java.util.List; public class ChainedBeanPersistController implements BeanPersistController { private static final Sorter SORTER = new Sorter(); - + private final List list; private final BeanPersistController[] chain; - + /** * Construct adding 2 BeanPersistController's. */ public ChainedBeanPersistController(BeanPersistController c1, BeanPersistController c2) { this(addList(c1, c2)); } - + /** * Helper method used to create a list from 2 BeanPersistController's. */ private static List addList(BeanPersistController c1, BeanPersistController c2) { - ArrayList addList = new ArrayList(2); + ArrayList addList = new ArrayList<>(2); addList.add(c1); addList.add(c2); return addList; } - + /** * Construct given the list of BeanPersistController's. */ @@ -62,14 +62,14 @@ public class ChainedBeanPersistController implements BeanPersistController { if (list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPersistController(newList); } } - + /** * De-register a BeanPersistController and return the resulting chain. */ @@ -77,14 +77,14 @@ public class ChainedBeanPersistController implements BeanPersistController { if (!list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPersistController(newList); } } - + /** * Always returns 0 (not used for this object). */ @@ -103,69 +103,69 @@ public class ChainedBeanPersistController implements BeanPersistController { @Override public void postDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postDelete(request); - } + for (BeanPersistController aChain : chain) { + aChain.postDelete(request); + } } @Override public void postInsert(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postInsert(request); - } + for (BeanPersistController aChain : chain) { + aChain.postInsert(request); + } } @Override public void postUpdate(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postUpdate(request); - } + for (BeanPersistController aChain : chain) { + aChain.postUpdate(request); + } } @Override public void postSoftDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postSoftDelete(request); - } + for (BeanPersistController aChain : chain) { + aChain.postSoftDelete(request); + } } @Override public boolean preDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preDelete(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preDelete(request)) { + return false; + } + } return true; } @Override public boolean preSoftDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preSoftDelete(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preSoftDelete(request)) { + return false; + } + } return true; } @Override public boolean preInsert(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preInsert(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preInsert(request)) { + return false; + } + } return true; } @Override public boolean preUpdate(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preUpdate(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preUpdate(request)) { + return false; + } + } return true; } @@ -175,11 +175,11 @@ public class ChainedBeanPersistController implements BeanPersistController { private static class Sorter implements Comparator { public int compare(BeanPersistController o1, BeanPersistController o2) { - + int i1 = o1.getExecutionOrder() ; int i2 = o2.getExecutionOrder() ; return (i1 list; - + private final BeanPersistListener[] chain; - + /** * Construct adding 2 BeanPersistListener's. */ @@ -39,12 +39,12 @@ public class ChainedBeanPersistListener implements BeanPersistListener { * Helper method used to create a list from 2 BeanPersistListener. */ private static List addList(BeanPersistListener c1, BeanPersistListener c2) { - ArrayList addList = new ArrayList(2); + ArrayList addList = new ArrayList<>(2); addList.add(c1); addList.add(c2); return addList; } - + /** * Construct given the list of BeanPersistListener's. */ @@ -52,7 +52,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener { this.list = list; this.chain = list.toArray(new BeanPersistListener[list.size()]); } - + /** * Register a new BeanPersistListener and return the resulting chain. */ @@ -60,14 +60,14 @@ public class ChainedBeanPersistListener implements BeanPersistListener { if (list.contains(c)){ return this; } else { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPersistListener(newList); } } - + /** * De-register a BeanPersistListener and return the resulting chain. */ @@ -75,35 +75,35 @@ public class ChainedBeanPersistListener implements BeanPersistListener { if (!list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPersistListener(newList); } } public void deleted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].deleted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.deleted(bean); + } } public void softDeleted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].softDeleted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.softDeleted(bean); + } } public void inserted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].inserted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.inserted(bean); + } } public void updated(Object bean, Set updatedProperties) { - for (int i = 0; i < chain.length; i++) { - chain[i].updated(bean, updatedProperties); - } + for (BeanPersistListener aChain : chain) { + aChain.updated(bean, updatedProperties); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java index 4ec842e07..b02d4d945 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java @@ -29,7 +29,7 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen if (list.contains(c)) { return this; } else { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); @@ -44,7 +44,7 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen if (!list.contains(c)) { return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); @@ -70,22 +70,22 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen */ @Override public void postConstruct(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postConstruct(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.postConstruct(bean); } } @Override public void autowire(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].autowire(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.autowire(bean); } } @Override public void postCreate(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postCreate(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.postCreate(bean); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java index ab31a33a7..316b054a4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java @@ -21,7 +21,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad { this.list = list; this.chain = list.toArray(new BeanPostLoad[list.size()]); } - + /** * Register a new BeanPostLoad and return the resulting chain. */ @@ -29,14 +29,14 @@ public class ChainedBeanPostLoad implements BeanPostLoad { if (list.contains(c)){ return this; } else { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPostLoad(newList); } } - + /** * De-register a BeanPostLoad and return the resulting chain. */ @@ -44,10 +44,10 @@ public class ChainedBeanPostLoad implements BeanPostLoad { if (!list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPostLoad(newList); } } @@ -70,8 +70,8 @@ public class ChainedBeanPostLoad implements BeanPostLoad { */ @Override public void postLoad(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postLoad(bean); - } + for (BeanPostLoad aChain : chain) { + aChain.postLoad(bean); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java index 4745e7f6b..4d609c0bf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java @@ -14,7 +14,7 @@ import com.avaje.ebean.event.BeanQueryRequest; public class ChainedBeanQueryAdapter implements BeanQueryAdapter { private static final Sorter SORTER = new Sorter(); - + private final List list; private final BeanQueryAdapter[] chain; @@ -28,7 +28,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { Arrays.sort(c, SORTER); this.chain = c; } - + /** * Register a new BeanQueryAdapter and return the resulting chain. */ @@ -36,14 +36,14 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { if (list.contains(c)){ return this; } else { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanQueryAdapter(newList); } } - + /** * De-register a BeanQueryAdapter and return the resulting chain. */ @@ -51,15 +51,15 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { if (!list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanQueryAdapter(newList); } } - + /** * Return 0 as not used by this Chained adapter. */ @@ -75,10 +75,10 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { } public void preQuery(BeanQueryRequest request) { - - for (int i = 0; i < chain.length; i++) { - chain[i].preQuery(request); - } + + for (BeanQueryAdapter aChain : chain) { + aChain.preQuery(request); + } } /** * Helper to order the BeanQueryAdapter's in a chain. @@ -86,11 +86,11 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { private static class Sorter implements Comparator { public int compare(BeanQueryAdapter o1, BeanQueryAdapter o2) { - + int i1 = o1.getExecutionOrder() ; int i2 = o2.getExecutionOrder() ; return (i1 beanDescriptor; - private final Set includes = new HashSet(); + private final Set includes = new HashSet<>(); public DeployPropertyParser(BeanDescriptor beanDescriptor) { this.beanDescriptor = beanDescriptor; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java index 2ad49241b..4a419b29c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java @@ -31,7 +31,7 @@ public class InheritInfo { private final Class type; - private final ArrayList children = new ArrayList(); + private final ArrayList children = new ArrayList<>(); /** * Map of discriminator values to InheritInfo. @@ -64,8 +64,8 @@ public class InheritInfo { if (r == null) { // this is a root node root = this; - discMap = new HashMap(); - typeMap = new HashMap(); + discMap = new HashMap<>(); + typeMap = new HashMap<>(); registerWithRoot(this); } else { @@ -82,8 +82,7 @@ public class InheritInfo { */ public void visitChildren(InheritInfoVisitor visitor) { - for (int i = 0; i < children.size(); i++) { - InheritInfo child = children.get(i); + for (InheritInfo child : children) { visitor.visit(child); child.visitChildren(visitor); } @@ -94,15 +93,12 @@ public class InheritInfo { */ public void appendCheckConstraintValues(final String propertyName, final Set checkConstraintValues) { - visitChildren(new InheritInfoVisitor() { - @Override - public void visit(InheritInfo inheritInfo) { - BeanProperty prop = inheritInfo.desc().getBeanProperty(propertyName); - if (prop != null) { - Set values = prop.getDbCheckConstraintValues(); - if (values != null) { - checkConstraintValues.addAll(values); - } + visitChildren(inheritInfo -> { + BeanProperty prop = inheritInfo.desc().getBeanProperty(propertyName); + if (prop != null) { + Set values = prop.getDbCheckConstraintValues(); + if (values != null) { + checkConstraintValues.addAll(values); } } }); @@ -120,8 +116,7 @@ public class InheritInfo { if (!descriptor.isSaveRecurseSkippable()) { return false; } - for (int i = 0; i < children.size(); i++) { - InheritInfo child = children.get(i); + for (InheritInfo child : children) { if (!child.isNodeSaveRecurseSkippable()) { return false; } @@ -141,8 +136,7 @@ public class InheritInfo { if (!descriptor.isDeleteRecurseSkippable()) { return false; } - for (int i = 0; i < children.size(); i++) { - InheritInfo child = children.get(i); + for (InheritInfo child : children) { if (!child.isNodeDeleteRecurseSkippable()) { return false; } @@ -179,8 +173,7 @@ public class InheritInfo { BeanProperty prop; - for (int i = 0, x = children.size(); i < x; i++) { - InheritInfo childInfo = children.get(i); + for (InheritInfo childInfo : children) { // recursively search this child bean descriptor prop = childInfo.desc().findBeanProperty(propertyName); if (prop != null) { @@ -196,8 +189,7 @@ public class InheritInfo { */ public void addChildrenProperties(SqlTreeProperties selectProps) { - for (int i = 0, x = children.size(); i < x; i++) { - InheritInfo childInfo = children.get(i); + for (InheritInfo childInfo : children) { selectProps.add(childInfo.descriptor.propertiesLocal()); childInfo.addChildrenProperties(selectProps); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/IntersectionRow.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/IntersectionRow.java index 3d0a48a65..49225a35d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/IntersectionRow.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/IntersectionRow.java @@ -18,7 +18,7 @@ public class IntersectionRow { private final BeanDescriptor targetDescriptor; - private final LinkedHashMap values = new LinkedHashMap(); + private final LinkedHashMap values = new LinkedHashMap<>(); private ArrayList excludeIds; private BeanDescriptor excludeDescriptor; @@ -100,8 +100,8 @@ public class IntersectionRow { sb.append(" ) "); List bindValues = er.getBindValues(); - for (int i = 0; i < bindValues.size(); i++) { - bindParams.setParameter(++count, bindValues.get(i)); + for (Object bindValue : bindValues) { + bindParams.setParameter(++count, bindValue); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java index 992fb2c6f..efdd8518a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java @@ -20,17 +20,17 @@ public class ParamTypeUtil { * @param matchType the type which has the generic parameter */ public static Class findParamType(Class cls, Class matchType) { - + // search for: implementing a generic interface Type paramType = matchByInterfaces(cls, matchType); if (paramType == null){ // search for: extending a generic class Type genericSuperclass = cls.getGenericSuperclass(); if (genericSuperclass != null){ - paramType = matchParamType(genericSuperclass, matchType); + paramType = matchParamType(genericSuperclass, matchType); } } - + if (paramType instanceof Class){ // only interested in classes return (Class)paramType; @@ -38,7 +38,7 @@ public class ParamTypeUtil { return null; } } - + /** * Check if the type is a generic one with parameters and of the correct type we are * searching for. Return the parameter type if this matches otherwise return null. @@ -60,19 +60,19 @@ public class ParamTypeUtil { } return null; } - + /** * Search the interfaces this class implements. */ private static Type matchByInterfaces(Class cls, Class matchType) { - + Type[] gis = cls.getGenericInterfaces(); - for (int i = 0; i < gis.length; i++) { - Type match = matchParamType(gis[i], matchType); - if (match != null){ - return match; - } - } + for (Type gi : gis) { + Type match = matchParamType(gi, matchType); + if (match != null) { + return match; + } + } return null; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java index 1c5e09e47..c57eec213 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java @@ -31,8 +31,7 @@ public class PersistControllerManager { */ public void addPersistControllers(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPersistController c = list.get(i); + for (BeanPersistController c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPersistController on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPersistController(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java index c1b0f981d..4cc9771e7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java @@ -31,13 +31,12 @@ public class PersistListenerManager { */ public void addPersistListeners(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPersistListener listener = list.get(i); + for (BeanPersistListener listener : list) { if (listener.isRegisterFor(deployDesc.getBeanType())) { - logger.debug("BeanPersistListener on[{}] {}", deployDesc.getFullName(), listener.getClass().getName()); - deployDesc.addPersistListener(listener); - } - } + logger.debug("BeanPersistListener on[{}] {}", deployDesc.getFullName(), listener.getClass().getName()); + deployDesc.addPersistListener(listener); + } + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java index 8e7a84041..50c879656 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java @@ -30,8 +30,7 @@ public class PostConstructManager { */ public void addPostConstructListeners(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPostConstructListener c = list.get(i); + for (BeanPostConstructListener c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPostLoad on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPostConstructListener(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java index c049b8f15..b4288411c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java @@ -30,8 +30,7 @@ public class PostLoadManager { */ public void addPostLoad(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPostLoad c = list.get(i); + for (BeanPostLoad c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPostLoad on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPostLoad(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java index 1d1e86ecf..6241519c6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java @@ -22,7 +22,7 @@ public final class TableJoin { private final SqlJoinType type; private final InheritInfo inheritInfo; - + /** * Columns as an array. */ @@ -56,9 +56,9 @@ public final class TableJoin { */ private int calcQueryHash() { int hc = type.hashCode(); - hc = hc * 31 + (table == null ? 0 : table.hashCode()); - for (int i = 0; i < columns.length; i++) { - hc = hc * 31 + columns[i].queryHash(); + hc = hc * 92821 + (table == null ? 0 : table.hashCode()); + for (TableJoinColumn column : columns) { + hc = hc * 92821 + column.queryHash(); } return hc; } @@ -99,8 +99,8 @@ public final class TableJoin { public String toString() { StringBuilder sb = new StringBuilder(30); sb.append(type).append(" ").append(table).append(" "); - for (int i = 0; i < columns.length; i++) { - sb.append(columns[i]).append(" "); + for (TableJoinColumn column : columns) { + sb.append(column).append(" "); } return sb.toString(); } @@ -141,8 +141,8 @@ public final class TableJoin { String joinLiteral = joinType.getLiteral(type); ctx.addJoin(joinLiteral, table, columns(), a1, a2, inheritance); - + return joinType.autoToOuter(type); } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java index 59a77f77f..4c5314a72 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java @@ -13,14 +13,19 @@ public class TableJoinColumn { */ private final String localDbColumn; + private final String localSqlFormula; + /** * The foreign database column name. */ private final String foreignDbColumn; + + private final String foreignSqlFormula; private final boolean insertable; private final boolean updateable; + /** * Hash for including in a query plan @@ -33,6 +38,9 @@ public class TableJoinColumn { public TableJoinColumn(DeployTableJoinColumn deploy) { this.localDbColumn = InternString.intern(deploy.getLocalDbColumn()); this.foreignDbColumn = InternString.intern(deploy.getForeignDbColumn()); + this.localSqlFormula = InternString.intern(deploy.getLocalSqlFormula()); + this.foreignSqlFormula = InternString.intern(deploy.getForeignSqlFormula()); + this.insertable = deploy.isInsertable(); this.updateable = deploy.isUpdateable(); this.queryHash = hash(); @@ -40,9 +48,12 @@ public class TableJoinColumn { int hash() { int result = localDbColumn != null ? localDbColumn.hashCode() : 0; - result = 31 * result + (foreignDbColumn != null ? foreignDbColumn.hashCode() : 0); - result = 31 * result + (insertable ? 1 : 0); - result = 31 * result + (updateable ? 1 : 0); + result = 92821 * result + (foreignDbColumn != null ? foreignDbColumn.hashCode() : 0); + result = 92821 * result + (localSqlFormula != null ? localSqlFormula.hashCode() : 0); + result = 92821 * result + (foreignSqlFormula != null ? foreignSqlFormula.hashCode() : 0); + result = 92821 * result + (insertable ? 1 : 0); + result = 92821 * result + (updateable ? 1 : 0); + return result; } @@ -64,7 +75,8 @@ public class TableJoinColumn { } public String toString() { - return localDbColumn + " = " + foreignDbColumn; + return (localSqlFormula == null ? localDbColumn : localSqlFormula) + " = " + + (foreignSqlFormula == null ? foreignDbColumn : foreignSqlFormula); } /** @@ -101,4 +113,13 @@ public class TableJoinColumn { public boolean isUpdateable() { return updateable; } + + public String getLocalSqlFormula() { + return localSqlFormula; + } + + public String getForeignSqlFormula() { + return foreignSqlFormula; + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java index 890b6581f..a9e0bd32d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java @@ -25,7 +25,7 @@ public class GeneratedPropertyFactory { private final UpdateTimestampFactory updateFactory; - private final HashSet numberTypes = new HashSet(); + private final HashSet numberTypes = new HashSet<>(); private final GeneratedWhoModified generatedWhoModified; @@ -33,7 +33,7 @@ public class GeneratedPropertyFactory { private final ClassLoadConfig classLoadConfig; - private final Map idGeneratorMap = new HashMap(); + private final Map idGeneratorMap = new HashMap<>(); public GeneratedPropertyFactory(ServerConfig serverConfig, List idGenerators) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/InsertTimestampFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/InsertTimestampFactory.java index c07426bbe..b1a510507 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/InsertTimestampFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/InsertTimestampFactory.java @@ -19,7 +19,7 @@ public class InsertTimestampFactory { final GeneratedInsertLong longTime = new GeneratedInsertLong(); - final Map, GeneratedProperty> map = new HashMap, GeneratedProperty>(); + final Map, GeneratedProperty> map = new HashMap<>(); public InsertTimestampFactory(ClassLoadConfig classLoadConfig) { map.put(Timestamp.class, new GeneratedInsertTimestamp()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactory.java index dd7c1653a..1e9f005e6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactory.java @@ -19,7 +19,7 @@ public class UpdateTimestampFactory { final GeneratedUpdateLong longTime = new GeneratedUpdateLong(); - final Map, GeneratedProperty> map = new HashMap, GeneratedProperty>(); + final Map, GeneratedProperty> map = new HashMap<>(); public UpdateTimestampFactory(ClassLoadConfig classLoadConfig) { map.put(Timestamp.class, new GeneratedUpdateTimestamp()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java index 1dc7f4a88..6576e3c7b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java @@ -117,15 +117,15 @@ public final class IdBinderEmbedded implements IdBinder { prefix = SplitName.add(prefix, embIdProperty.getName()); - for (int i = 0; i < props.length; i++) { - props[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty prop : props) { + prop.buildRawSqlSelectChain(prefix, selectChain); } } public BeanProperty findBeanProperty(String dbColumnName) { - for (int i = 0; i < props.length; i++) { - if (dbColumnName.equalsIgnoreCase(props[i].getDbColumn())) { - return props[i]; + for (BeanProperty prop : props) { + if (dbColumnName.equalsIgnoreCase(prop.getDbColumn())) { + return prop; } } return null; @@ -156,8 +156,8 @@ public final class IdBinderEmbedded implements IdBinder { } public void addIdInBindValue(SpiExpressionRequest request, Object value) { - for (int i = 0; i < props.length; i++) { - request.addBindValue(props[i].getValue((EntityBean) value)); + for (BeanProperty prop : props) { + request.addBindValue(prop.getValue((EntityBean) value)); } } @@ -234,9 +234,9 @@ public final class IdBinderEmbedded implements IdBinder { public Object getIdForJson(EntityBean bean) { EntityBean ebValue = (EntityBean)embIdProperty.getValue(bean); - Map map = new LinkedHashMap(); - for (int i = 0; i < props.length; i++) { - map.put(props[i].getName(), props[i].getValue(ebValue)); + Map map = new LinkedHashMap<>(); + for (BeanProperty prop : props) { + map.put(prop.getName(), prop.getValue(ebValue)); } return map; } @@ -244,31 +244,32 @@ public final class IdBinderEmbedded implements IdBinder { /** * Convert back from a Map to embedded bean. */ + @SuppressWarnings("unchecked") public Object convertIdFromJson(Object value) { Map map = (Map)value; EntityBean idValue = idDesc.createEntityBean(); - for (int i = 0; i < props.length; i++) { - Object val = map.get(props[i].getName()); - props[i].setValue(idValue, val); + for (BeanProperty prop : props) { + Object val = map.get(prop.getName()); + prop.setValue(idValue, val); } return idValue; } public void bindId(DefaultSqlUpdate sqlUpdate, Object value) { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) value); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) value); sqlUpdate.addParameter(embFieldValue); } } public void bindId(DataBind dataBind, Object value) throws SQLException { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) value); - props[i].bind(dataBind, embFieldValue); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) value); + prop.bind(dataBind, embFieldValue); } } @@ -277,9 +278,9 @@ public final class IdBinderEmbedded implements IdBinder { EntityBean embId = idDesc.createEntityBean(); boolean notNull = true; - for (int i = 0; i < props.length; i++) { - Object value = props[i].readData(dataInput); - props[i].setValue(embId, value); + for (BeanProperty prop : props) { + Object value = prop.readData(dataInput); + prop.setValue(embId, value); if (value == null) { notNull = false; } @@ -293,15 +294,15 @@ public final class IdBinderEmbedded implements IdBinder { } public void writeData(DataOutput dataOutput, Object idValue) throws IOException { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) idValue); - props[i].writeData(dataOutput, embFieldValue); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) idValue); + prop.writeData(dataOutput, embFieldValue); } } public void loadIgnore(DbReadContext ctx) { - for (int i = 0; i < props.length; i++) { - props[i].loadIgnore(ctx); + for (BeanProperty prop : props) { + prop.loadIgnore(ctx); } } @@ -310,8 +311,8 @@ public final class IdBinderEmbedded implements IdBinder { EntityBean embId = idDesc.createEntityBean(); boolean notNull = true; - for (int i = 0; i < props.length; i++) { - Object value = props[i].readSet(ctx, embId); + for (BeanProperty prop : props) { + Object value = prop.readSet(ctx, embId); if (value == null) { notNull = false; } @@ -336,8 +337,8 @@ public final class IdBinderEmbedded implements IdBinder { } public void appendSelect(DbSqlContext ctx, boolean subQuery) { - for (int i = 0; i < props.length; i++) { - props[i].appendSelect(ctx, subQuery); + for (BeanProperty prop : props) { + prop.appendSelect(ctx, subQuery); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java index 099315d9b..dc29e59b3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java @@ -52,15 +52,15 @@ public class ImportedIdEmbedded implements ImportedId { } public void sqlAppend(DbSqlContext ctx) { - for (int i = 0; i < imported.length; i++) { - ctx.appendColumn(imported[i].localDbColumn); + for (ImportedIdSimple anImported : imported) { + ctx.appendColumn(anImported.localDbColumn); } } public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < imported.length; i++) { - request.appendColumn(imported[i].localDbColumn); + for (ImportedIdSimple anImported : imported) { + request.appendColumn(anImported.localDbColumn); } } @@ -83,9 +83,9 @@ public class ImportedIdEmbedded implements ImportedId { int pos = position; EntityBean embedded = (EntityBean) foreignAssocOne.getValue(bean); - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - Object scalarValue = imported[i].foreignProperty.getValue(embedded); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + Object scalarValue = anImported.foreignProperty.getValue(embedded); update.setParameter(pos++, scalarValue); } } @@ -101,18 +101,18 @@ public class ImportedIdEmbedded implements ImportedId { } if (embeddedId == null) { - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - request.bind(null, imported[i].foreignProperty); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + request.bind(null, anImported.foreignProperty); } } } else { EntityBean embedded = (EntityBean) embeddedId; - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - Object scalarValue = imported[i].foreignProperty.getValue(embedded); - request.bind(scalarValue, imported[i].foreignProperty); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + Object scalarValue = anImported.foreignProperty.getValue(embedded); + request.bind(scalarValue, anImported.foreignProperty); } } } @@ -128,9 +128,9 @@ public class ImportedIdEmbedded implements ImportedId { throw new PersistenceException(msg); } - for (int i = 0; i < imported.length; i++) { - Object scalarValue = imported[i].foreignProperty.getValue(embeddedId); - row.put(imported[i].localDbColumn, scalarValue); + for (ImportedIdSimple anImported : imported) { + Object scalarValue = anImported.foreignProperty.getValue(embeddedId); + row.put(anImported.localDbColumn, scalarValue); } } @@ -140,8 +140,8 @@ public class ImportedIdEmbedded implements ImportedId { */ public BeanProperty findMatchImport(String matchDbColumn) { - for (int i = 0; i < imported.length; i++) { - BeanProperty p = imported[i].findMatchImport(matchDbColumn); + for (ImportedIdSimple anImported : imported) { + BeanProperty p = anImported.findMatchImport(matchDbColumn); if (p != null) { return p; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdSimple.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdSimple.java index 85fdf7b17..06ac324b9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdSimple.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdSimple.java @@ -37,6 +37,8 @@ public final class ImportedIdSimple implements ImportedId, Comparable owner; protected final String localDbColumn; + + protected final String localSqlFormula; protected final String logicalName; @@ -44,9 +46,10 @@ public final class ImportedIdSimple implements ImportedId, Comparable owner, String localDbColumn, BeanProperty foreignProperty, int position) { + public ImportedIdSimple(BeanPropertyAssoc owner, String localDbColumn, String localSqlFormula, BeanProperty foreignProperty, int position) { this.owner = owner; this.localDbColumn = InternString.intern(localDbColumn); + this.localSqlFormula = InternString.intern(localSqlFormula); this.foreignProperty = foreignProperty; this.position = position; this.logicalName = InternString.intern(owner.getName() + "." + foreignProperty.getName()); @@ -103,7 +106,11 @@ public final class ImportedIdSimple implements ImportedId, Comparable { - private static final Map EMPTY_NAMED_QUERY = new HashMap(); + private static final Map EMPTY_NAMED_QUERY = new HashMap<>(); - private static final Map EMPTY_RAW_MAP = new HashMap(); + private static final Map EMPTY_RAW_MAP = new HashMap<>(); private static class PropOrder implements Comparator { @@ -73,7 +73,7 @@ public class DeployBeanDescriptor { /** * Map of BeanProperty Linked so as to preserve order. */ - private LinkedHashMap propMap = new LinkedHashMap(); + private LinkedHashMap propMap = new LinkedHashMap<>(); private Map namedRawSql; @@ -153,11 +153,11 @@ public class DeployBeanDescriptor { */ private final Class beanType; - private final List persistControllers = new ArrayList(); - private final List persistListeners = new ArrayList(); - private final List queryAdapters = new ArrayList(); - private final List postLoaders = new ArrayList(); - private final List postConstructListeners = new ArrayList(); + private final List persistControllers = new ArrayList<>(); + private final List persistListeners = new ArrayList<>(); + private final List queryAdapters = new ArrayList<>(); + private final List postLoaders = new ArrayList<>(); + private final List postConstructListeners = new ArrayList<>(); private CacheOptions cacheOptions = CacheOptions.NO_CACHING; @@ -169,7 +169,7 @@ public class DeployBeanDescriptor { /** * The table joins for this bean. Server side only. */ - private final ArrayList tableJoinList = new ArrayList(2); + private final ArrayList tableJoinList = new ArrayList<>(2); /** * Inheritance information. Server side only. @@ -302,8 +302,8 @@ public class DeployBeanDescriptor { public boolean isScalaObject() { Class[] interfaces = beanType.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - String iname = interfaces[i].getName(); + for (Class anInterface : interfaces) { + String iname = anInterface.getName(); if (I_SCALAOBJECT.equals(iname)) { return true; } @@ -454,7 +454,7 @@ public class DeployBeanDescriptor { */ public void addIndex(IndexDefinition c) { if (indexDefinitions == null) { - indexDefinitions = new ArrayList(); + indexDefinitions = new ArrayList<>(); } indexDefinitions.add(c); } @@ -546,7 +546,7 @@ public class DeployBeanDescriptor { return new ChainedBeanPostConstructListener(postConstructListeners); } } - + public void addPersistController(BeanPersistController controller) { persistControllers.add(controller); } @@ -566,7 +566,7 @@ public class DeployBeanDescriptor { public void addPostConstructListener(BeanPostConstructListener postConstructListener) { postConstructListeners.add(postConstructListener); } - + public String getDraftTable() { return draftTable; } @@ -629,14 +629,14 @@ public class DeployBeanDescriptor { public void sortProperties() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll(propMap.values()); Collections.sort(list, PROP_ORDER); - propMap = new LinkedHashMap(list.size()); - for (int i = 0; i < list.size(); i++) { - addBeanProperty(list.get(i)); + propMap = new LinkedHashMap<>(list.size()); + for (DeployBeanProperty aList : list) { + addBeanProperty(aList); } } @@ -917,7 +917,7 @@ public class DeployBeanDescriptor { public List propertiesId() { if (idProperties == null) { - idProperties = new ArrayList(2); + idProperties = new ArrayList<>(2); for (DeployBeanProperty prop : propMap.values()) { if (prop.isId()) { idProperties.add(prop); @@ -945,7 +945,7 @@ public class DeployBeanDescriptor { */ public List> propertiesAssocOne() { - ArrayList> list = new ArrayList>(); + ArrayList> list = new ArrayList<>(); for (DeployBeanProperty prop : propMap.values()) { if (prop instanceof DeployBeanPropertyAssocOne) { @@ -964,7 +964,7 @@ public class DeployBeanDescriptor { */ public List> propertiesAssocMany() { - ArrayList> list = new ArrayList>(); + ArrayList> list = new ArrayList<>(); for (DeployBeanProperty prop : propMap.values()) { if (prop instanceof DeployBeanPropertyAssocMany) { @@ -980,7 +980,7 @@ public class DeployBeanDescriptor { */ public List propertiesBase() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for (DeployBeanProperty prop : propMap.values()) { if (!(prop instanceof DeployBeanPropertyAssoc) && !prop.isId()) { @@ -1089,7 +1089,7 @@ public class DeployBeanDescriptor { */ public void addNamedQuery(String name, String query) { if (namedQuery == null) { - namedQuery = new LinkedHashMap(); + namedQuery = new LinkedHashMap<>(); } namedQuery.put(name, query); } @@ -1106,7 +1106,7 @@ public class DeployBeanDescriptor { */ public void addRawSql(String name, RawSql rawSql) { if (namedRawSql == null) { - namedRawSql = new HashMap(); + namedRawSql = new HashMap<>(); } namedRawSql.put(name, rawSql); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanEmbedded.java index a85e63200..48f1db521 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanEmbedded.java @@ -15,7 +15,7 @@ public class DeployBeanEmbedded { /** * A map of property names to dbColumns. */ - private final Map propMap = new HashMap(); + private final Map propMap = new HashMap<>(); /** * Set a Map of property names to dbColumns. diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocOne.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocOne.java index 686a3e4f2..c9391d010 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocOne.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocOne.java @@ -96,4 +96,13 @@ public class DeployBeanPropertyAssocOne extends DeployBeanPropertyAssoc { tableJoin.setLocalColumn(dbColumn); } } + + @Override + public void setSqlFormula(String formulaSelect, String formulaJoin) { + super.setSqlFormula(formulaSelect, formulaJoin); + DeployTableJoinColumn[] columns = tableJoin.columns(); + if (columns.length == 1) { + columns[0].setLocalSqlFormula(formulaSelect); + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java index b0666e501..3c055d507 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java @@ -35,29 +35,29 @@ public class DeployBeanPropertyLists { private final LinkedHashMap propertyMap; - private final List ids = new ArrayList(); + private final List ids = new ArrayList<>(); - private final List local = new ArrayList(); + private final List local = new ArrayList<>(); - private final List mutable = new ArrayList(); + private final List mutable = new ArrayList<>(); - private final List> manys = new ArrayList>(); - - private final List nonManys = new ArrayList(); + private final List> manys = new ArrayList<>(); - private final List> ones = new ArrayList>(); + private final List nonManys = new ArrayList<>(); - private final List> onesImported = new ArrayList>(); + private final List> ones = new ArrayList<>(); - private final List> embedded = new ArrayList>(); + private final List> onesImported = new ArrayList<>(); - private final List baseScalar = new ArrayList(); + private final List> embedded = new ArrayList<>(); - private final List baseCompound = new ArrayList(); + private final List baseScalar = new ArrayList<>(); - private final List transients = new ArrayList(); + private final List baseCompound = new ArrayList<>(); - private final List nonTransients = new ArrayList(); + private final List transients = new ArrayList<>(); + + private final List nonTransients = new ArrayList<>(); private final TableJoin[] tableJoins; @@ -76,7 +76,7 @@ public class DeployBeanPropertyLists { unidirectional = new BeanPropertyAssocOne(owner, desc, deployUnidirectional); } - this.propertyMap = new LinkedHashMap(); + this.propertyMap = new LinkedHashMap<>(); // see if there is a discriminator property we should add String discriminatorColumn = null; @@ -179,7 +179,7 @@ public class DeployBeanPropertyLists { if (prop.isMutableScalarType()) { mutable.add(prop); } - + if (desc.getInheritInfo() != null && prop.isLocal()) { local.add(prop); } @@ -214,7 +214,9 @@ public class DeployBeanPropertyLists { if (prop instanceof BeanPropertyCompound) { baseCompound.add((BeanPropertyCompound) prop); } else { - baseScalar.add(prop); + if (!prop.isAggregation()) { + baseScalar.add(prop); + } } } } @@ -346,23 +348,22 @@ public class DeployBeanPropertyLists { } private BeanPropertyAssocOne[] getOne(boolean imported, Mode mode) { - ArrayList> list = new ArrayList>(); - for (int i = 0; i < ones.size(); i++) { - BeanPropertyAssocOne prop = ones.get(i); + ArrayList> list = new ArrayList<>(); + for (BeanPropertyAssocOne prop : ones) { if (imported != prop.isOneToOneExported()) { switch (mode) { - case Save: - if (prop.getCascadeInfo().isSave()) { - list.add(prop); - } - break; - case Delete: - if (prop.getCascadeInfo().isDelete()) { - list.add(prop); - } - break; - default: - break; + case Save: + if (prop.getCascadeInfo().isSave()) { + list.add(prop); + } + break; + case Delete: + if (prop.getCascadeInfo().isDelete()) { + list.add(prop); + } + break; + default: + break; } } } @@ -371,9 +372,8 @@ public class DeployBeanPropertyLists { } private BeanPropertyAssocMany[] getMany2Many() { - ArrayList> list = new ArrayList>(); - for (int i = 0; i < manys.size(); i++) { - BeanPropertyAssocMany prop = manys.get(i); + ArrayList> list = new ArrayList<>(); + for (BeanPropertyAssocMany prop : manys) { if (prop.isManyToMany()) { list.add(prop); } @@ -383,28 +383,26 @@ public class DeployBeanPropertyLists { } private BeanPropertyAssocMany[] getMany(Mode mode) { - ArrayList> list = new ArrayList>(); - for (int i = 0; i < manys.size(); i++) { - BeanPropertyAssocMany prop = manys.get(i); - + ArrayList> list = new ArrayList<>(); + for (BeanPropertyAssocMany prop : manys) { switch (mode) { - case Save: - if (prop.getCascadeInfo().isSave() || prop.isManyToMany() + case Save: + if (prop.getCascadeInfo().isSave() || prop.isManyToMany() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { - // Note ManyToMany always included as we always 'save' - // the relationship via insert/delete of intersection table - // REMOVALS means including PrivateOwned relationships - list.add(prop); - } - break; - case Delete: - if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { - // REMOVALS means including PrivateOwned relationships - list.add(prop); - } - break; - default: - break; + // Note ManyToMany always included as we always 'save' + // the relationship via insert/delete of intersection table + // REMOVALS means including PrivateOwned relationships + list.add(prop); + } + break; + case Delete: + if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { + // REMOVALS means including PrivateOwned relationships + list.add(prop); + } + break; + default: + break; } } @@ -417,15 +415,15 @@ public class DeployBeanPropertyLists { if (deployProp instanceof DeployBeanPropertyAssocOne) { return new BeanPropertyAssocOne(owner, desc, (DeployBeanPropertyAssocOne) deployProp); } - + if (deployProp instanceof DeployBeanPropertySimpleCollection) { return new BeanPropertySimpleCollection(desc, (DeployBeanPropertySimpleCollection) deployProp); } - + if (deployProp instanceof DeployBeanPropertyAssocMany) { return new BeanPropertyAssocMany(desc, (DeployBeanPropertyAssocMany) deployProp); } - + if (deployProp instanceof DeployBeanPropertyCompound) { return new BeanPropertyCompound(desc, (DeployBeanPropertyCompound) deployProp); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java index 9ef4fb95a..54211867a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java @@ -29,7 +29,7 @@ public class DeployTableJoin { /** * The list of join column pairs. Used to generate the on clause. */ - private ArrayList columns = new ArrayList(4); + private ArrayList columns = new ArrayList<>(4); private InheritInfo inheritInfo; @@ -54,9 +54,9 @@ public class DeployTableJoin { * Copy all the columns to this join potentially reversing the columns. */ public void setColumns(DeployTableJoinColumn[] cols, boolean reverse) { - columns = new ArrayList(); - for (int i = 0; i < cols.length; i++) { - addJoinColumn(cols[i].copy(reverse)); + columns = new ArrayList<>(); + for (DeployTableJoinColumn col : cols) { + addJoinColumn(col.copy(reverse)); } } @@ -87,8 +87,8 @@ public class DeployTableJoin { * Add a JoinColumn array. */ public void addJoinColumn(boolean order, JoinColumn[] jcArray, BeanTable beanTable) { - for (int i = 0; i < jcArray.length; i++) { - addJoinColumn(order, jcArray[i], beanTable); + for (JoinColumn aJcArray : jcArray) { + addJoinColumn(order, aJcArray, beanTable); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java index cc2a8ca50..293857cdc 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java @@ -15,14 +15,26 @@ public class DeployTableJoinColumn { */ String localDbColumn; + /** + * SQL formula used for local column + */ + String localSqlFormula; + /** * The foreign database column name. */ String foreignDbColumn; + + /** + * SQL formula used for foreign column + */ + String foreignSqlFormula; - final boolean insertable; + boolean insertable; + + boolean updateable; + - final boolean updateable; /** * Construct when automatically determining the join. @@ -43,7 +55,34 @@ public class DeployTableJoinColumn { this.insertable = insertable; this.updateable = updateable; } - + + public void setLocalSqlFormula(String localSqlFormula) { + if (localSqlFormula != null) { + this.localSqlFormula = localSqlFormula; + this.localDbColumn = null; + this.insertable = false; + this.updateable = false; + } + } + + public String getLocalSqlFormula() { + return localSqlFormula; + } + + public void setForeignSqlFormula(String foreignSqlFormula) { + if (foreignSqlFormula != null) { + this.foreignSqlFormula = foreignSqlFormula; + this.foreignDbColumn = null; + this.insertable = false; + this.updateable = false; + } + } + + public String getForeignSqlFormula() { + return foreignSqlFormula; + } + + public DeployTableJoinColumn(boolean order, JoinColumn jc, BeanTable beanTable) { this(jc.referencedColumnName(), jc.name(), jc.insertable(), jc.updatable()); setReferencedColumn(beanTable); @@ -68,6 +107,10 @@ public class DeployTableJoinColumn { String temp = localDbColumn; localDbColumn = foreignDbColumn; foreignDbColumn = temp; + + temp = localSqlFormula; + localSqlFormula = foreignSqlFormula; + foreignSqlFormula = temp; return this; } @@ -86,12 +129,18 @@ public class DeployTableJoinColumn { // Note that the insertable and updateable are just copied // which may not always be the correct thing to do // but will leave it like this for now + DeployTableJoinColumn ret; if (reverse){ - return new DeployTableJoinColumn(foreignDbColumn, localDbColumn, insertable, updateable); + ret = new DeployTableJoinColumn(foreignDbColumn, localDbColumn, insertable, updateable); + ret.setLocalSqlFormula(foreignSqlFormula); + ret.setForeignSqlFormula(localSqlFormula); } else { - return new DeployTableJoinColumn(localDbColumn, foreignDbColumn, insertable, updateable); + ret = new DeployTableJoinColumn(localDbColumn, foreignDbColumn, insertable, updateable); + ret.setLocalSqlFormula(localSqlFormula); + ret.setForeignSqlFormula(foreignSqlFormula); } + return ret; } public String toString() { @@ -132,4 +181,5 @@ public class DeployTableJoinColumn { public void setLocalDbColumn(String localDbColumn) { this.localDbColumn = localDbColumn; } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java index a67bde018..064de0d4d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java @@ -133,7 +133,7 @@ public class AnnotationAssocManys extends AnnotationParser { // Use the owning bean table to define the join BeanTable owningBeanTable = factory.getBeanTable(descriptor.getBeanType()); - owningBeanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), false); + owningBeanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), false, prop.getSqlFormulaSelect()); } } @@ -225,20 +225,20 @@ public class AnnotationAssocManys extends AnnotationParser { if (!intJoin.hasJoinColumns()) { // define foreign key columns BeanProperty[] localIds = localTable.getIdProperties(); - for (int i = 0; i < localIds.length; i++) { + for (BeanProperty localId : localIds) { // add the source to intersection join columns - String fkCol = localTableName + "_" + localIds[i].getDbColumn(); - intJoin.addJoinColumn(new DeployTableJoinColumn(localIds[i].getDbColumn(), namingConvention.getColumnFromProperty(null, fkCol))); + String fkCol = localTableName + "_" + localId.getDbColumn(); + intJoin.addJoinColumn(new DeployTableJoinColumn(localId.getDbColumn(), namingConvention.getColumnFromProperty(null, fkCol))); } } if (!destJoin.hasJoinColumns()) { // define inverse foreign key columns BeanProperty[] otherIds = otherTable.getIdProperties(); - for (int i = 0; i < otherIds.length; i++) { + for (BeanProperty otherId : otherIds) { // set the intersection to dest table join columns - final String fkCol = otherTableName + "_" + otherIds[i].getDbColumn(); - destJoin.addJoinColumn(new DeployTableJoinColumn(namingConvention.getColumnFromProperty(null, fkCol), otherIds[i].getDbColumn())); + final String fkCol = otherTableName + "_" + otherId.getDbColumn(); + destJoin.addJoinColumn(new DeployTableJoinColumn(namingConvention.getColumnFromProperty(null, fkCol), otherId.getDbColumn())); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java index 73aeba43e..f95a19901 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java @@ -145,7 +145,7 @@ public class AnnotationAssocOnes extends AnnotationParser { fkeyPrefix = nc.getColumnFromProperty(beanType, prop.getName()); } - beanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), true); + beanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), true, prop.getSqlFormulaSelect()); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java index 21df2ac49..c116b6ed9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java @@ -138,7 +138,7 @@ public abstract class AnnotationBase { if (ann != null) { return ann; } else { - return findAnnotation(annotatedElement, annotationType, new HashSet()); + return findAnnotation(annotatedElement, annotationType, new HashSet<>()); } } @@ -158,7 +158,7 @@ public abstract class AnnotationBase { return ann; } else { while (clazz != null && clazz != Object.class) { - ann = findAnnotation(clazz, annotationType, new HashSet()); + ann = findAnnotation(clazz, annotationType, new HashSet<>()); if (ann != null) { return ann; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java index 22a9c11ed..78974b3d2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java @@ -13,6 +13,7 @@ import com.avaje.ebean.annotation.View; import com.avaje.ebean.config.TableName; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor.EntityType; import com.avaje.ebeaninternal.server.deploy.IndexDefinition; +import com.avaje.ebeaninternal.server.deploy.InheritInfo; import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -94,10 +95,13 @@ public class AnnotationClass extends AnnotationParser { private void setTableName() { if (descriptor.isBaseTableType()) { - + Class beanType = descriptor.getBeanType(); + InheritInfo inheritInfo = descriptor.getInheritInfo(); + if (inheritInfo != null) { + beanType = inheritInfo.getRoot().getType(); + } // default the TableName using NamingConvention. - TableName tableName = namingConvention.getTableName(descriptor.getBeanType()); - + TableName tableName = namingConvention.getTableName(beanType); descriptor.setBaseTable(tableName, asOfViewSuffix, versionsBetweenSuffix); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java index a8f301525..b8055b1fa 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -104,6 +104,11 @@ public class AnnotationFields extends AnnotationParser { } readEmbeddedAttributeOverrides((DeployBeanPropertyAssocOne) prop); } + + Formula formula = get(prop, Formula.class); + if (formula != null) { + prop.setSqlFormula(formula.select(), formula.join()); + } } private void readField(DeployBeanProperty prop) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java index b56f1ee3c..31d269a3e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -26,7 +26,7 @@ public abstract class AnnotationParser extends AnnotationBase { protected final Class beanType; protected final boolean validationAnnotations; - + public AnnotationParser(DeployBeanInfo info, boolean validationAnnotations) { super(info.getUtil()); this.validationAnnotations = validationAnnotations; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployBeanInfo.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployBeanInfo.java index 63ffc3801..ac7543d1b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployBeanInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployBeanInfo.java @@ -16,7 +16,7 @@ public class DeployBeanInfo { /** * Holds TableJoins for secondary table properties. */ - private final HashMap tableJoinMap = new HashMap(); + private final HashMap tableJoinMap = new HashMap<>(); private final DeployUtil util; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java index f1a4224e8..272c81b86 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java @@ -38,7 +38,7 @@ import java.lang.reflect.Type; public class DeployCreateProperties { private static final Logger logger = LoggerFactory.getLogger(DeployCreateProperties.class); - + private final DetermineManyType determineManyType; private final TypeManager typeManager; @@ -183,10 +183,9 @@ public class DeployCreateProperties { String methIsName = "is" + initFieldName; String scalaGet = field.getName(); - for (int i = 0; i < declaredMethods.length; i++) { - Method m = declaredMethods[i]; + for (Method m : declaredMethods) { if ((scalaObject && m.getName().equals(scalaGet)) || m.getName().equals(methGetName) - || m.getName().equals(methIsName)) { + || m.getName().equals(methIsName)) { Class[] params = m.getParameterTypes(); if (params.length == 0) { @@ -222,7 +221,7 @@ public class DeployCreateProperties { private DeployBeanProperty createProp(DeployBeanDescriptor desc, Field field) { Class propertyType = field.getType(); - + ManyToOne manyToOne = AnnotationBase.findAnnotation(field,ManyToOne.class); if (manyToOne != null){ Class tt = manyToOne.targetEntity(); @@ -233,7 +232,7 @@ public class DeployCreateProperties { if (isSpecialScalarType(field)) { return new DeployBeanProperty(desc, propertyType, field.getGenericType()); } - + // check for Collection type (list, set or map) ManyType manyType = determineManyType.getManyType(propertyType); if (manyType != null) { @@ -303,7 +302,7 @@ public class DeployCreateProperties { || (AnnotationBase.findAnnotation(field,DbArray.class) != null) || (AnnotationBase.findAnnotation(field,DbHstore.class) != null); } - + private boolean isTransientField(Field field) { Transient t = AnnotationBase.findAnnotation(field,Transient.class); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInherit.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInherit.java index b110798f9..a1eec01bd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInherit.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInherit.java @@ -19,9 +19,9 @@ import java.util.Map; */ public class DeployInherit { - private final Map, DeployInheritInfo> deployMap = new LinkedHashMap, DeployInheritInfo>(); + private final Map, DeployInheritInfo> deployMap = new LinkedHashMap<>(); - private final Map, InheritInfo> finalMap = new LinkedHashMap, InheritInfo>(); + private final Map, InheritInfo> finalMap = new LinkedHashMap<>(); private final BootupClasses bootupClasses; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInheritInfo.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInheritInfo.java index 6c45bdd52..3964c5d23 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInheritInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInheritInfo.java @@ -32,7 +32,7 @@ public class DeployInheritInfo { private Class parent; - private final ArrayList children = new ArrayList(); + private final ArrayList children = new ArrayList<>(); /** * Create for a given type. @@ -202,7 +202,7 @@ public class DeployInheritInfo { public String getWhere() { - List discList = new ArrayList(); + List discList = new ArrayList<>(); appendDiscriminator(discList); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java index 6ac806c88..736ee30af 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java @@ -117,21 +117,37 @@ public class DeployUtil { throw new IllegalArgumentException("Class [" + enumType + "] is Not a Enum?"); } ScalarType scalarType = typeManager.getScalarType(enumType); + if (enumOverrideDefaultMapping(enumerated, scalarType)) { + logger.debug("override default enum mapping for type {}", enumType); + scalarType = null; + } if (scalarType == null) { // look for @DbEnumValue or @EnumValue annotations etc - scalarType = typeManager.createEnumScalarType((Class>)enumType); + Class> enumClass = (Class>)enumType; + scalarType = typeManager.createEnumScalarType(enumClass); if (scalarType == null) { // use JPA normal Enum type (without mapping) EnumType type = enumerated != null ? enumerated.value() : null; scalarType = createEnumScalarTypePerSpec(enumType, type); } - typeManager.add(scalarType); + typeManager.addEnumType(scalarType, enumClass); } prop.setScalarType(scalarType); prop.setDbType(scalarType.getJdbcType()); } + /** + * Return true if there is an existing default mapping for the enum that needs + * to be overridden (for example, DayOfWeek defaults to Integer mapping 1 to 7 + * and some might want this mapped to 'MONDAY' etc). + */ + private boolean enumOverrideDefaultMapping(Enumerated enumerated, ScalarType scalarType) { + return enumerated != null && scalarType != null + && enumerated.value() == EnumType.STRING + && scalarType.getJdbcType() != Types.VARCHAR; + } + private ScalarType createEnumScalarTypePerSpec(Class enumType, EnumType type) { if (type == null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java index 96beb0fdc..24afe1ed3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java @@ -10,7 +10,7 @@ import java.util.HashSet; */ public class SqlReservedWords { - private static final String baseKeyWords = + private static final String baseKeyWords = "ALIAS,ALTER,ADD,ALL,ARE,AND,ANY,ARRAY" +",AS,ASC,AT" +",AVG,BEGIN,BETWEEN,BIGINT,BINARY,BIT,BIT_LENGTH,BLOB,BOOLEAN" @@ -44,15 +44,15 @@ public class SqlReservedWords { +",UPDATE,USER,VARCHAR,VIEW,WHEN" +",WHERE,WITH"; - - private static final HashSet keywords = new HashSet(); + + private static final HashSet keywords = new HashSet<>(); static { - + String[] initialKeywords = baseKeyWords.split(","); - for (int i = 0; i < initialKeywords.length; i++) { - keywords.add(initialKeywords[i].trim()); - } - + for (String initialKeyword : initialKeywords) { + keywords.add(initialKeyword.trim()); + } + } @@ -63,7 +63,7 @@ public class SqlReservedWords { String s = keyword.trim().toUpperCase(); return keywords.contains(s); } - + /** * Add a sql keyword to the known set. */ @@ -71,7 +71,7 @@ public class SqlReservedWords { if (keyword != null){ keyword = keyword.trim().toUpperCase(); if (!keyword.isEmpty()){ - keywords.add(keyword); + keywords.add(keyword); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java index 0d119f0d4..2f8b52d9f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java @@ -11,41 +11,38 @@ import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; * Mark transient properties. */ public class TransientProperties { - + public TransientProperties() { } - + /** * Mark any additional properties as transient. */ public void process(DeployBeanDescriptor desc) { - + List props = desc.propertiesBase(); - for (int i = 0; i < props.size(); i++) { - DeployBeanProperty prop = props.get(i); - if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) { - // non-transient... - prop.setTransient(); - } - } + for (DeployBeanProperty prop : props) { + if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) { + // non-transient... + prop.setTransient(); + } + } List> ones = desc.propertiesAssocOne(); - for (int i = 0; i < ones.size(); i++) { - DeployBeanPropertyAssocOne prop = ones.get(i); - if (prop.getBeanTable() == null) { - if (!prop.isEmbedded()) { - prop.setTransient(); - } - } + for (DeployBeanPropertyAssocOne prop : ones) { + if (prop.getBeanTable() == null) { + if (!prop.isEmbedded()) { + prop.setTransient(); + } } + } List> manys = desc.propertiesAssocMany(); - for (int i = 0; i < manys.size(); i++) { - DeployBeanPropertyAssocMany prop = manys.get(i); - if (prop.getBeanTable() == null) { - prop.setTransient(); - } + for (DeployBeanPropertyAssocMany prop : manys) { + if (prop.getBeanTable() == null) { + prop.setTransient(); } - + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java index 663a92043..9f77d986f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java @@ -18,8 +18,8 @@ public final class ElComparatorCompound implements Comparator, ElComparato public int compare(T o1, T o2) { - for (int i = 0; i < array.length; i++) { - int ret = array[i].compare(o1, o2); + for (ElComparator anArray : array) { + int ret = anArray.compare(o1, o2); if (ret != 0) { return ret; } @@ -30,8 +30,8 @@ public final class ElComparatorCompound implements Comparator, ElComparato public int compareValue(Object value, T o2) { - for (int i = 0; i < array.length; i++) { - int ret = array[i].compareValue(value, o2); + for (ElComparator anArray : array) { + int ret = anArray.compareValue(value, o2); if (ret != 0) { return ret; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java index 9ef9a520c..a6f80a0f3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.el; +import com.avaje.ebean.Filter; +import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; + import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.regex.Pattern; -import com.avaje.ebean.Filter; -import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; - /** * Default implementation of the Filter interface. */ @@ -15,7 +15,7 @@ public final class ElFilter implements Filter { private final BeanDescriptor beanDescriptor; - private final ArrayList> matches = new ArrayList>(); + private final ArrayList> matches = new ArrayList<>(); private int maxRows; @@ -47,8 +47,7 @@ public final class ElFilter implements Filter { } protected boolean isMatch(T bean) { - for (int i = 0; i < matches.size(); i++) { - ElMatcher matcher = matches.get(i); + for (ElMatcher matcher : matches) { if (!matcher.isMatch(bean)) { return false; } @@ -61,7 +60,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.InSet(matchingValues, elGetValue)); + matches.add(new ElMatchBuilder.InSet<>(matchingValues, elGetValue)); return this; } @@ -70,7 +69,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Eq(value, comparator)); + matches.add(new ElMatchBuilder.Eq<>(value, comparator)); return this; } @@ -80,7 +79,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Ne(value, comparator)); + matches.add(new ElMatchBuilder.Ne<>(value, comparator)); return this; } @@ -92,7 +91,7 @@ public final class ElFilter implements Filter { ElComparator elComparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Between(min, max, elComparator)); + matches.add(new ElMatchBuilder.Between<>(min, max, elComparator)); return this; } @@ -102,7 +101,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Gt(value, comparator)); + matches.add(new ElMatchBuilder.Gt<>(value, comparator)); return this; } @@ -111,7 +110,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Ge(value, comparator)); + matches.add(new ElMatchBuilder.Ge<>(value, comparator)); return this; } @@ -119,7 +118,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.Ieq(elGetValue, value)); + matches.add(new ElMatchBuilder.Ieq<>(elGetValue, value)); return this; } @@ -128,7 +127,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.IsNotNull(elGetValue)); + matches.add(new ElMatchBuilder.IsNotNull<>(elGetValue)); return this; } @@ -137,7 +136,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.IsNull(elGetValue)); + matches.add(new ElMatchBuilder.IsNull<>(elGetValue)); return this; } @@ -147,7 +146,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Le(value, comparator)); + matches.add(new ElMatchBuilder.Le<>(value, comparator)); return this; } @@ -157,7 +156,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Lt(value, comparator)); + matches.add(new ElMatchBuilder.Lt<>(value, comparator)); return this; } @@ -169,7 +168,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.RegularExpr(elGetValue, regEx, options)); + matches.add(new ElMatchBuilder.RegularExpr<>(elGetValue, regEx, options)); return this; } @@ -178,7 +177,7 @@ public final class ElFilter implements Filter { String quote = ".*" + Pattern.quote(value) + ".*"; ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.RegularExpr(elGetValue, quote, 0)); + matches.add(new ElMatchBuilder.RegularExpr<>(elGetValue, quote, 0)); return this; } @@ -187,7 +186,7 @@ public final class ElFilter implements Filter { String quote = ".*" + Pattern.quote(value) + ".*"; ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.RegularExpr(elGetValue, quote, Pattern.CASE_INSENSITIVE)); + matches.add(new ElMatchBuilder.RegularExpr<>(elGetValue, quote, Pattern.CASE_INSENSITIVE)); return this; } @@ -195,28 +194,28 @@ public final class ElFilter implements Filter { public Filter endsWith(String propertyName, String value) { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.EndsWith(elGetValue, value)); + matches.add(new ElMatchBuilder.EndsWith<>(elGetValue, value)); return this; } public Filter startsWith(String propertyName, String value) { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.StartsWith(elGetValue, value)); + matches.add(new ElMatchBuilder.StartsWith<>(elGetValue, value)); return this; } public Filter iendsWith(String propertyName, String value) { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.IEndsWith(elGetValue, value)); + matches.add(new ElMatchBuilder.IEndsWith<>(elGetValue, value)); return this; } public Filter istartsWith(String propertyName, String value) { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.IStartsWith(elGetValue, value)); + matches.add(new ElMatchBuilder.IStartsWith<>(elGetValue, value)); return this; } @@ -229,14 +228,13 @@ public final class ElFilter implements Filter { if (sortByClause != null) { // create shallow copy and sort - list = new ArrayList(list); + list = new ArrayList<>(list); beanDescriptor.sort(list, sortByClause); } - ArrayList filterList = new ArrayList(); + ArrayList filterList = new ArrayList<>(); - for (int i = 0; i < list.size(); i++) { - T t = list.get(i); + for (T t : list) { if (isMatch(t)) { filterList.add(t); if (maxRows > 0 && filterList.size() >= maxRows) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElMatchBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElMatchBuilder.java index f488860e1..b8554445b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElMatchBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElMatchBuilder.java @@ -224,7 +224,7 @@ class ElMatchBuilder { public boolean isMatch(T value) { return (comparator.compareValue(min, value) <= 0 - && comparator.compareValue(max, value) >= 0); + && comparator.compareValue(max, value) >= 0); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java index dcb9a0c19..4d298ca4f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java @@ -193,8 +193,8 @@ public class ElPropertyChain implements ElPropertyValue { } public boolean isAssocProperty() { - for (int i = 0; i < chain.length; i++) { - if (chain[i].isAssocProperty()) { + for (ElPropertyValue aChain : chain) { + if (aChain.isAssocProperty()) { return true; } } @@ -233,8 +233,8 @@ public class ElPropertyChain implements ElPropertyValue { @Override public Object pathGet(Object bean) { - for (int i = 0; i < chain.length; i++) { - bean = chain[i].pathGet(bean); + for (ElPropertyValue aChain : chain) { + bean = aChain.pathGet(bean); if (bean == null) { return null; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChainBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChainBuilder.java index 946e8d1fc..d8b681858 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChainBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChainBuilder.java @@ -17,7 +17,7 @@ public class ElPropertyChainBuilder { private final String expression; - private final List chain = new ArrayList(); + private final List chain = new ArrayList<>(); private final boolean embedded; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java index bef1ee0bc..0325a322d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java @@ -49,7 +49,7 @@ class AllEqualsExpression extends NonPrepareExpression { @Override public void validate(SpiExpressionValidation validation) { - for (String propName: propMap.keySet()) { + for (String propName : propMap.keySet()) { validation.validate(propName); } } @@ -120,9 +120,9 @@ class AllEqualsExpression extends NonPrepareExpression { @Override public int queryBindHash() { - int hc = 31; + int hc = 92821; for (Object value : propMap.values()) { - hc = hc * 31 + (value == null ? 0 : value.hashCode()); + hc = hc * 92821 + (value == null ? 0 : value.hashCode()); } return hc; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java index a90c13cf7..b65eed668 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java @@ -35,8 +35,8 @@ public class ArrayContainsExpression extends AbstractExpression { } else { context.startBoolMustNot(); } - for (int i = 0; i < values.length; i++) { - context.writeEqualTo(propName, values[i]); + for (Object value : values) { + context.writeEqualTo(propName, value); } context.endBool(); } @@ -52,7 +52,7 @@ public class ArrayContainsExpression extends AbstractExpression { public int queryBindHash() { int hc = values[0].hashCode(); for (int i = 1; i < values.length; i++) { - hc = hc * 31 + values[i].hashCode(); + hc = hc * 92821 + values[i].hashCode(); } return hc; } @@ -64,8 +64,8 @@ public class ArrayContainsExpression extends AbstractExpression { } ArrayContainsExpression that = (ArrayContainsExpression) other; return this.propName.equals(that.propName) - && this.contains == that.contains - && this.values.length == that.values.length; + && this.contains == that.contains + && this.values.length == that.values.length; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java index 741fcf26f..2b7338c9e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java @@ -30,7 +30,7 @@ public class ArrayIsEmptyExpression extends AbstractExpression { @Override public int queryBindHash() { - return empty ? 0 : 31; + return empty ? 0 : 92821; } @Override @@ -39,8 +39,7 @@ public class ArrayIsEmptyExpression extends AbstractExpression { return false; } ArrayIsEmptyExpression that = (ArrayIsEmptyExpression) other; - return this.propName.equals(that.propName) - && this.empty == that.empty; + return this.propName.equals(that.propName) && this.empty == that.empty; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java index a07970e8d..9888e89fd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java @@ -54,7 +54,7 @@ class BetweenExpression extends AbstractExpression { @Override public int queryBindHash() { int hc = low().hashCode(); - hc = hc * 31 + high().hashCode(); + hc = hc * 92821 + high().hashCode(); return hc; } @@ -71,7 +71,6 @@ class BetweenExpression extends AbstractExpression { @Override public boolean isSameByBind(SpiExpression other) { BetweenExpression that = (BetweenExpression) other; - return low().equals(that.low()) - && high().equals(that.high()); + return low().equals(that.low()) && high().equals(that.high()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenPropertyExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenPropertyExpression.java index 1a5958989..d8cc71871 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenPropertyExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenPropertyExpression.java @@ -103,8 +103,7 @@ class BetweenPropertyExpression extends NonPrepareExpression { } BetweenPropertyExpression that = (BetweenPropertyExpression) other; - return lowProperty.equals(that.lowProperty) - && highProperty.equals(that.highProperty); + return lowProperty.equals(that.lowProperty) && highProperty.equals(that.highProperty); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java index f8491c300..9bb9041e9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java @@ -82,7 +82,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio DefaultExampleExpression(ArrayList source) { this.entity = null; - this.list = new ArrayList(source.size()); + this.list = new ArrayList<>(source.size()); for (SpiExpression expression : source) { list.add(expression.copyForPlanKey()); } @@ -124,8 +124,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { list = buildExpressions(desc); if (list != null) { - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, whereManyJoins); + for (SpiExpression aList : list) { + aList.containsMany(desc, whereManyJoins); } } } @@ -173,8 +173,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public void validate(SpiExpressionValidation validation) { - for (int i = 0; i < list.size(); i++) { - list.get(i).validate(validation); + for (SpiExpression aList : list) { + aList.validate(validation); } } @@ -184,8 +184,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < list.size(); i++) { - SpiExpression item = list.get(i); + for (SpiExpression item : list) { item.addBindValues(request); } } @@ -218,8 +217,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(DefaultExampleExpression.class); - for (int i = 0; i < list.size(); i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -229,10 +228,9 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public int queryBindHash() { int hc = DefaultExampleExpression.class.getName().hashCode(); - for (int i = 0; i < list.size(); i++) { - hc = hc * 31 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hc = hc * 92821 + aList.queryBindHash(); } - return hc; } @@ -273,7 +271,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio */ private ArrayList buildExpressions(BeanDescriptor beanDescriptor) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); addExpressions(list, beanDescriptor, entity, null); return list; } @@ -291,7 +289,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio String propName = SplitName.add(prefix, beanProperty.getName()); if (beanProperty.isScalar()) { if (value instanceof String) { - list.add(new LikeExpression(propName, (String) value, caseInsensitive, likeType)); + list.add(new LikeExpression(propName, value, caseInsensitive, likeType)); } else { // exclude the zero values typically to weed out // primitive int and long that initialise to 0 @@ -301,8 +299,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio } } else if ((beanProperty instanceof BeanPropertyAssocOne) && (value instanceof EntityBean)) { - BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) beanProperty; - BeanDescriptor targetDescriptor = assocOne.getTargetDescriptor(); + BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) beanProperty; + BeanDescriptor targetDescriptor = assocOne.getTargetDescriptor(); addExpressions(list, targetDescriptor, (EntityBean) value, propName); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java index 5115a8ae3..3bcc1392c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java @@ -26,7 +26,7 @@ import java.util.Map; */ public class DefaultExpressionFactory implements SpiExpressionFactory { - private static final Object[] EMPTY_ARRAY = new Object[] {}; + private static final Object[] EMPTY_ARRAY = new Object[]{}; private final boolean nativeIlike; @@ -37,7 +37,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { this.nativeIlike = nativeIlike; } - public ExpressionFactory createExpressionFactory(){ + public ExpressionFactory createExpressionFactory() { return this; } @@ -233,9 +233,9 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { if (bean == null || (!(bean instanceof EntityBean))) { throw new IllegalStateException("Expecting an EntityBean"); } - return (EntityBean)bean; + return (EntityBean) bean; } - + /** * Case insensitive {@link #exampleLike(Object)} */ @@ -372,19 +372,19 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { } /** - * Exists subquery + * Exists subquery */ @Override public Expression exists(Query subQuery) { - return new ExistsQueryExpression((SpiQuery) subQuery, false); + return new ExistsQueryExpression((SpiQuery) subQuery, false); } - + /** - * Not exists subquery + * Not exists subquery */ @Override public Expression notExists(Query subQuery) { - return new ExistsQueryExpression((SpiQuery) subQuery, true); + return new ExistsQueryExpression((SpiQuery) subQuery, true); } @Override @@ -427,9 +427,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { * Expression where all the property names in the map are equal to the * corresponding value. *

- * - * @param propertyMap - * a map keyed by property names. + * + * @param propertyMap a map keyed by property names. */ public Expression allEq(Map propertyMap) { return new AllEqualsExpression(propertyMap); @@ -443,7 +442,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { *

*/ public Expression raw(String raw, Object value) { - return new RawExpression(raw, new Object[] { value }); + return new RawExpression(raw, new Object[]{value}); } /** @@ -492,35 +491,35 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { * Return a list of expressions that will be joined by AND's. */ public Junction conjunction(Query query) { - return new JunctionExpression(Junction.Type.AND, query, query.where()); + return new JunctionExpression<>(Junction.Type.AND, query, query.where()); } /** * Return a list of expressions that will be joined by OR's. */ public Junction disjunction(Query query) { - return new JunctionExpression(Junction.Type.OR, query, query.where()); + return new JunctionExpression<>(Junction.Type.OR, query, query.where()); } /** * Return a list of expressions that will be joined by AND's. */ public Junction conjunction(Query query, ExpressionList parent) { - return new JunctionExpression(Junction.Type.AND, query, parent); + return new JunctionExpression<>(Junction.Type.AND, query, parent); } /** * Return a list of expressions that will be joined by OR's. */ public Junction disjunction(Query query, ExpressionList parent) { - return new JunctionExpression(Junction.Type.OR, query, parent); + return new JunctionExpression<>(Junction.Type.OR, query, parent); } /** * Return a list of expressions that are wrapped by NOT. */ public Junction junction(Junction.Type type, Query query) { - return new JunctionExpression(type, query, query.where()); + return new JunctionExpression<>(type, query, query.where()); } /** @@ -528,6 +527,6 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { */ @Override public Junction junction(Junction.Type type, Query query, ExpressionList parent) { - return new JunctionExpression(type, query, parent); + return new JunctionExpression<>(type, query, parent); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java index 497317fcf..381e93e86 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java @@ -1,6 +1,20 @@ package com.avaje.ebeaninternal.server.expression; -import com.avaje.ebean.*; +import com.avaje.ebean.Expression; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.FetchPath; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.Junction; +import com.avaje.ebean.OrderBy; +import com.avaje.ebean.PagedList; +import com.avaje.ebean.Query; +import com.avaje.ebean.QueryEachConsumer; +import com.avaje.ebean.QueryEachWhileConsumer; +import com.avaje.ebean.QueryIterator; +import com.avaje.ebean.Version; import com.avaje.ebean.event.BeanQueryRequest; import com.avaje.ebean.search.Match; import com.avaje.ebean.search.MultiMatch; @@ -50,7 +64,7 @@ public class DefaultExpressionList implements SpiExpressionList { * Construct for Text root expression list - this handles implicit Bool Should, Must etc. */ public DefaultExpressionList(Query query) { - this(query, query.getExpressionFactory(), null, new ArrayList(), true); + this(query, query.getExpressionFactory(), null, new ArrayList<>(), true); } public DefaultExpressionList(Query query, ExpressionList parentExprList) { @@ -58,7 +72,7 @@ public class DefaultExpressionList implements SpiExpressionList { } DefaultExpressionList(Query query, ExpressionFactory expr, ExpressionList parentExprList) { - this(query, expr, parentExprList, new ArrayList()); + this(query, expr, parentExprList, new ArrayList<>()); } DefaultExpressionList(Query query, ExpressionFactory expr, ExpressionList parentExprList, List list) { @@ -74,7 +88,7 @@ public class DefaultExpressionList implements SpiExpressionList { } private DefaultExpressionList() { - this(null, null, null, new ArrayList()); + this(null, null, null, new ArrayList<>()); } /** @@ -87,11 +101,11 @@ public class DefaultExpressionList implements SpiExpressionList { */ SpiExpression wrap(List list, String nestedPath, Junction.Type type) { - DefaultExpressionList wrapper = new DefaultExpressionList(query, expr, null, list, false); + DefaultExpressionList wrapper = new DefaultExpressionList<>(query, expr, null, list, false); wrapper.setAllDocNested(nestedPath); if (type != null) { - return new JunctionExpression(type, wrapper); + return new JunctionExpression<>(type, wrapper); } else { return wrapper; } @@ -103,6 +117,11 @@ public class DefaultExpressionList implements SpiExpressionList { } } + @Override + public Junction toJunction() { + return new JunctionExpression<>(Junction.Type.FILTER, this); + } + public void simplify() { simplifyEntries(); } @@ -126,7 +145,7 @@ public class DefaultExpressionList implements SpiExpressionList { // this is a Top level "text" expressions so we may need to wrap in Bool SHOULD etc. if (list.isEmpty()) throw new IllegalStateException("empty expression list?"); - if (allDocNestedPath!=null) context.startNested(allDocNestedPath); + if (allDocNestedPath != null) context.startNested(allDocNestedPath); int size = list.size(); SpiExpression first = list.get(0); @@ -139,11 +158,10 @@ public class DefaultExpressionList implements SpiExpressionList { if (implicitBool) { context.startBoolGroupList(Junction.Type.SHOULD); } - for (int i = 0; i < size; i++) { - SpiExpression expr = list.get(i); + for (SpiExpression expr : list) { if (explicitBool) { try { - ((SpiJunction)expr).writeDocQueryJunction(context); + ((SpiJunction) expr).writeDocQueryJunction(context); } catch (ClassCastException e) { throw new IllegalStateException("The top level text() expressions should be all be 'Must', 'Should' or 'Must Not' or none of them should be.", e); } @@ -157,13 +175,13 @@ public class DefaultExpressionList implements SpiExpressionList { if (implicitBool || explicitBool) { context.endBoolGroup(); } - if (allDocNestedPath!=null) context.endNested(); + if (allDocNestedPath != null) context.endNested(); } } public void writeDocQuery(DocQueryContext context, SpiExpression idEquals) throws IOException { - if (allDocNestedPath!=null) context.startNested(allDocNestedPath); + if (allDocNestedPath != null) context.startNested(allDocNestedPath); int size = list.size(); if (size == 1 && idEquals == null) { // only 1 expression - skip bool @@ -177,12 +195,12 @@ public class DefaultExpressionList implements SpiExpressionList { if (idEquals != null) { idEquals.writeDocQuery(context); } - for (int i = 0; i < size; i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBool(); } - if (allDocNestedPath!=null) context.endNested(); + if (allDocNestedPath != null) context.endNested(); } @Override @@ -201,13 +219,13 @@ public class DefaultExpressionList implements SpiExpressionList { *

*/ public DefaultExpressionList copy(Query query) { - DefaultExpressionList copy = new DefaultExpressionList(query, expr, null); + DefaultExpressionList copy = new DefaultExpressionList<>(query, expr, null); copy.list.addAll(list); return copy; } public DefaultExpressionList copyForPlanKey() { - DefaultExpressionList copy = new DefaultExpressionList(); + DefaultExpressionList copy = new DefaultExpressionList<>(); for (int i = 0; i < list.size(); i++) { copy.list.add(list.get(i).copyForPlanKey()); } @@ -226,15 +244,15 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, whereManyJoins); + for (SpiExpression aList : list) { + aList.containsMany(desc, whereManyJoins); } } @Override public void validate(SpiExpressionValidation validation) { - for (int i = 0; i < list.size(); i++) { - list.get(i).validate(validation); + for (SpiExpression aList : list) { + aList.validate(validation); } } @@ -480,15 +498,15 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).addBindValues(request); + for (SpiExpression aList : list) { + aList.addBindValues(request); } } @Override public void prepareExpression(BeanQueryRequest request) { - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).prepareExpression(request); + for (SpiExpression aList : list) { + aList.prepareExpression(request); } } @@ -499,8 +517,8 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(DefaultExpressionList.class); - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -510,8 +528,8 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public int queryBindHash() { int hash = DefaultExpressionList.class.getName().hashCode(); - for (int i = 0, size = list.size(); i < size; i++) { - hash = hash * 31 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hash = hash * 92821 + aList.queryBindHash(); } return hash; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java index 76f157b43..35b75c931 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java @@ -1,9 +1,5 @@ package com.avaje.ebeaninternal.server.expression; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.api.SpiExpressionList; import com.avaje.ebeaninternal.api.SpiExpressionRequest; import com.avaje.ebeaninternal.server.core.DbExpressionHandler; @@ -13,6 +9,10 @@ import com.avaje.ebeaninternal.server.deploy.DeployParser; import com.avaje.ebeaninternal.server.persist.Binder; import com.avaje.ebeaninternal.server.type.DataBind; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + public class DefaultExpressionRequest implements SpiExpressionRequest { private final SpiOrmQueryRequest queryRequest; @@ -21,7 +21,7 @@ public class DefaultExpressionRequest implements SpiExpressionRequest { private final StringBuilder sql = new StringBuilder(); - private final List bindValues = new ArrayList(); + private final List bindValues = new ArrayList<>(); private final DeployParser deployParser; @@ -63,8 +63,7 @@ public class DefaultExpressionRequest implements SpiExpressionRequest { * Bind the values from the underlying expression list. */ public void bind(DataBind dataBind) throws SQLException { - for (int i = 0; i < bindValues.size(); i++) { - Object bindValue = bindValues.get(i); + for (Object bindValue : bindValues) { binder.bindObject(dataBind, bindValue); } if (bindLog != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java index aa1abcfe7..8de510482 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java @@ -1,8 +1,5 @@ package com.avaje.ebeaninternal.server.expression; -import java.io.IOException; -import java.util.List; - import com.avaje.ebean.event.BeanQueryRequest; import com.avaje.ebeaninternal.api.HashQueryPlanBuilder; import com.avaje.ebeaninternal.api.ManyWhereJoins; @@ -14,6 +11,9 @@ import com.avaje.ebeaninternal.api.SpiQuery; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.query.CQuery; +import java.io.IOException; +import java.util.List; + class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpression { protected final boolean not; @@ -29,7 +29,7 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress this.not = not; } - ExistsQueryExpression(boolean not, String sql , List bindParams) { + ExistsQueryExpression(boolean not, String sql, List bindParams) { this.not = not; this.sql = sql; this.bindParams = bindParams; @@ -98,8 +98,8 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < bindParams.size(); i++) { - request.addBindValue(bindParams.get(i)); + for (Object bindParam : bindParams) { + request.addBindValue(bindParam); } } @@ -111,8 +111,8 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress ExistsQueryExpression that = (ExistsQueryExpression) other; return this.sql.equals(that.sql) - && this.not == that.not - && this.bindParams.size() == that.bindParams.size(); + && this.not == that.not + && this.bindParams.size() == that.bindParams.size(); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java index dc3852ef6..e9cf35d22 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java @@ -1,6 +1,12 @@ package com.avaje.ebeaninternal.server.expression; -import com.avaje.ebean.*; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.OrderBy; +import com.avaje.ebean.Query; import com.avaje.ebeaninternal.api.SpiExpressionList; import javax.persistence.PersistenceException; @@ -30,7 +36,7 @@ public class FilterExpressionList extends DefaultExpressionList { @Override public SpiExpressionList trimPath(int prefixTrim) { - return new FilterExpressionList(pathPrefix.trimPath(prefixTrim), this); + return new FilterExpressionList<>(pathPrefix.trimPath(prefixTrim), this); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java index c74767df2..d39931aea 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java @@ -50,8 +50,8 @@ class IdExpression extends NonPrepareExpression implements SpiExpression { // into an array of the underlying scalar field values DefaultExpressionRequest r = (DefaultExpressionRequest) request; Object[] bindIdValues = r.getBeanDescriptor().getBindIdValues(value); - for (int i = 0; i < bindIdValues.length; i++) { - request.addBindValue(bindIdValues[i]); + for (Object bindIdValue : bindIdValues) { + request.addBindValue(bindIdValue); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java index 3c153b9ad..2b329000a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java @@ -50,8 +50,8 @@ public class IdInExpression extends NonPrepareExpression { BeanDescriptor descriptor = r.getBeanDescriptor(); IdBinder idBinder = descriptor.getIdBinder(); - for (int i = 0; i < idList.size(); i++) { - idBinder.addIdInBindValue(request, idList.get(i)); + for (Object anIdList : idList) { + idBinder.addIdInBindValue(request, anIdList); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java index 89ad86c40..4abffd0e1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java @@ -34,7 +34,7 @@ class InExpression extends AbstractExpression { } private Object[] values() { - List vals = new ArrayList(); + List vals = new ArrayList<>(); for (Object sourceValue : sourceValues) { NamedParamHelp.valueAdd(vals, sourceValue); } @@ -59,16 +59,16 @@ class InExpression extends AbstractExpression { prop = null; } - for (int i = 0; i < bindValues.length; i++) { + for (Object bindValue : bindValues) { if (prop == null) { - request.addBindValue(bindValues[i]); + request.addBindValue(bindValue); } else { // extract the id values from the bean - Object[] ids = prop.getAssocIdValues((EntityBean) bindValues[i]); + Object[] ids = prop.getAssocIdValues((EntityBean) bindValue); if (ids != null) { - for (int j = 0; j < ids.length; j++) { - request.addBindValue(ids[j]); + for (Object id : ids) { + request.addBindValue(id); } } } @@ -119,9 +119,9 @@ class InExpression extends AbstractExpression { @Override public int queryBindHash() { - int hc = 31; - for (int i = 0; i < bindValues.length; i++) { - hc = 31 * hc + bindValues[i].hashCode(); + int hc = 92821; + for (Object bindValue : bindValues) { + hc = 92821 * hc + bindValue.hashCode(); } return hc; } @@ -134,8 +134,8 @@ class InExpression extends AbstractExpression { InExpression that = (InExpression) other; return propName.equals(that.propName) - && not == that.not - && bindValues.length == that.bindValues.length; + && not == that.not + && bindValues.length == that.bindValues.length; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java index ba1bd8857..2a7026dea 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java @@ -91,8 +91,8 @@ class InQueryExpression extends AbstractExpression implements UnsupportedDocStor @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < bindParams.size(); i++) { - request.addBindValue(bindParams.get(i)); + for (Object bindParam : bindParams) { + request.addBindValue(bindParam); } } @@ -104,9 +104,9 @@ class InQueryExpression extends AbstractExpression implements UnsupportedDocStor InQueryExpression that = (InQueryExpression) other; return propName.equals(that.propName) - && sql.equals(that.sql) - && not == that.not - && bindParams.size() == that.bindParams.size(); + && sql.equals(that.sql) + && not == that.not + && bindParams.size() == that.bindParams.size(); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java index 950bf0ef9..744bd4a0f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java @@ -41,12 +41,12 @@ class IsEmptyExpression extends AbstractExpression { if (nestedPath == null) { context.writeExists(!empty, propName); } else { - // wrap NOT around the outside of nested path exists expression - context.startNot(); + // wrap bool must not around the outside of nested path exists expression + context.startBoolMustNot(); context.startNested(nestedPath); context.writeExists(empty, propName); context.endNested(); - context.endNot(); + context.endBool(); } } @@ -85,9 +85,9 @@ class IsEmptyExpression extends AbstractExpression { request.append("not "); } request - .append("exists (select 1 from ") - .append(prop.getAssocIsEmpty(request, propertyPath)) - .append(")"); + .append("exists (select 1 from ") + .append(prop.getAssocIsEmpty(request, propertyPath)) + .append(")"); } /** @@ -110,8 +110,7 @@ class IsEmptyExpression extends AbstractExpression { } IsEmptyExpression that = (IsEmptyExpression) other; - return this.propName.equals(that.propName) - && this.empty == that.empty; + return this.propName.equals(that.propName) && this.empty == that.empty; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java index 778bbad18..63032bd38 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java @@ -79,7 +79,7 @@ class JsonPathExpression extends AbstractExpression { @Override public int queryBindHash() { int hc = (value == null) ? 0 : value.hashCode(); - hc = (upperValue == null) ? hc : hc * 31 + upperValue.hashCode(); + hc = (upperValue == null) ? hc : hc * 92821 + upperValue.hashCode(); return hc; } @@ -91,10 +91,10 @@ class JsonPathExpression extends AbstractExpression { JsonPathExpression that = (JsonPathExpression) other; return propName.equals(that.propName) - && operator == that.operator - && Same.sameByValue(path, that.path) - && Same.sameByNull(value, that.value) - && Same.sameByNull(upperValue, that.upperValue); + && operator == that.operator + && Same.sameByValue(path, that.path) + && Same.sameByNull(value, that.value) + && Same.sameByNull(upperValue, that.upperValue); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java index 6a3351d66..e3a25ee46 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java @@ -46,7 +46,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression JunctionExpression(Junction.Type type, Query query, ExpressionList parent) { this.type = type; - this.exprList = new DefaultExpressionList(query, parent); + this.exprList = new DefaultExpressionList<>(query, parent); } /** @@ -69,7 +69,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression List list = exprList.list; if (list.size() == 1 && list.get(0) instanceof JunctionExpression) { - JunctionExpression nested = (JunctionExpression)list.get(0); + JunctionExpression nested = (JunctionExpression) list.get(0); if (type == Type.AND && !nested.type.isText()) { // and (and (a, b, c)) -> and (a, b, c) // and (not (a, b, c)) -> not (a, b, c) @@ -84,15 +84,15 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression } public SpiExpression copyForPlanKey() { - return new JunctionExpression(type, exprList.copyForPlanKey()); + return new JunctionExpression<>(type, exprList.copyForPlanKey()); } @Override public void writeDocQuery(DocQueryContext context) throws IOException { context.startBool(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBool(); } @@ -101,8 +101,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void writeDocQueryJunction(DocQueryContext context) throws IOException { context.startBoolGroupList(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBoolGroupList(); } @@ -125,8 +125,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression manyWhereJoin.setRequireOuterJoins(true); } - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, manyWhereJoin); + for (SpiExpression aList : list) { + aList.containsMany(desc, manyWhereJoin); } if (type == Type.OR && !parentOuterJoins) { // restore state to not forcing outer joins @@ -155,8 +155,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void addBindValues(SpiExpressionRequest request) { List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).addBindValues(request); + for (SpiExpression aList : list) { + aList.addBindValues(request); } } @@ -182,8 +182,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression @Override public void prepareExpression(BeanQueryRequest request) { List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).prepareExpression(request); + for (SpiExpression aList : list) { + aList.prepareExpression(request); } } @@ -194,8 +194,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(JunctionExpression.class).add(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -203,8 +203,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public int queryBindHash() { int hc = JunctionExpression.class.getName().hashCode(); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - hc = hc * 31 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hc = hc * 92821 + aList.queryBindHash(); } return hc; } @@ -429,7 +429,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Path does not exist - for the given path in a JSON document. */ @Override - public ExpressionList jsonNotExists(String propertyName, String path){ + public ExpressionList jsonNotExists(String propertyName, String path) { return exprList.jsonNotExists(propertyName, path); } @@ -437,7 +437,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Equal to - for the value at the given path in the JSON document. */ @Override - public ExpressionList jsonEqualTo(String propertyName, String path, Object value){ + public ExpressionList jsonEqualTo(String propertyName, String path, Object value) { return exprList.jsonEqualTo(propertyName, path, value); } @@ -445,7 +445,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Not Equal to - for the given path in a JSON document. */ @Override - public ExpressionList jsonNotEqualTo(String propertyName, String path, Object val){ + public ExpressionList jsonNotEqualTo(String propertyName, String path, Object val) { return exprList.jsonNotEqualTo(propertyName, path, val); } @@ -453,7 +453,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Greater than - for the given path in a JSON document. */ @Override - public ExpressionList jsonGreaterThan(String propertyName, String path, Object val){ + public ExpressionList jsonGreaterThan(String propertyName, String path, Object val) { return exprList.jsonGreaterThan(propertyName, path, val); } @@ -461,7 +461,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Greater than or equal to - for the given path in a JSON document. */ @Override - public ExpressionList jsonGreaterOrEqual(String propertyName, String path, Object val){ + public ExpressionList jsonGreaterOrEqual(String propertyName, String path, Object val) { return exprList.jsonGreaterOrEqual(propertyName, path, val); } @@ -469,7 +469,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Less than - for the given path in a JSON document. */ @Override - public ExpressionList jsonLessThan(String propertyName, String path, Object val){ + public ExpressionList jsonLessThan(String propertyName, String path, Object val) { return exprList.jsonLessThan(propertyName, path, val); } @@ -477,7 +477,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Less than or equal to - for the given path in a JSON document. */ @Override - public ExpressionList jsonLessOrEqualTo(String propertyName, String path, Object val){ + public ExpressionList jsonLessOrEqualTo(String propertyName, String path, Object val) { return exprList.jsonLessOrEqualTo(propertyName, path, val); } @@ -485,7 +485,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Between - for the given path in a JSON document. */ @Override - public ExpressionList jsonBetween(String propertyName, String path, Object lowerValue, Object upperValue){ + public ExpressionList jsonBetween(String propertyName, String path, Object lowerValue, Object upperValue) { return exprList.jsonBetween(propertyName, path, lowerValue, upperValue); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/LikeExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/LikeExpression.java index 7e4b330e3..f34de403a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/LikeExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/LikeExpression.java @@ -82,8 +82,8 @@ class LikeExpression extends AbstractValueExpression { LikeExpression that = (LikeExpression) other; return this.propName.equals(that.propName) - && this.caseInsensitive == that.caseInsensitive - && this.type == that.type; + && this.caseInsensitive == that.caseInsensitive + && this.type == that.type; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java index 44281d369..67d4ac8fe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java @@ -146,7 +146,7 @@ abstract class LogicExpression implements SpiExpression { @Override public int queryBindHash() { int hc = expOne.queryBindHash(); - hc = hc * 31 + expTwo.queryBindHash(); + hc = hc * 92821 + expTwo.queryBindHash(); return hc; } @@ -159,15 +159,15 @@ abstract class LogicExpression implements SpiExpression { LogicExpression that = (LogicExpression) other; return this.joinType.equals(that.joinType) - && this.expOne.isSameByPlan(that.expOne) - && this.expTwo.isSameByPlan(that.expTwo); + && this.expOne.isSameByPlan(that.expOne) + && this.expTwo.isSameByPlan(that.expTwo); } @Override public boolean isSameByBind(SpiExpression other) { LogicExpression that = (LogicExpression) other; return this.expOne.isSameByBind(that.expOne) - && this.expTwo.isSameByBind(that.expTwo); + && this.expTwo.isSameByBind(that.expTwo); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java b/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java index 1defe77e5..cda7e69d9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java @@ -35,7 +35,7 @@ class NamedParamHelp { Object value = value(sourceValue); if (value instanceof Collection) { - values.addAll((Collection)value); + values.addAll((Collection) value); } else { values.add(value); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/NestedPathWrapperExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/NestedPathWrapperExpression.java index 6f4434486..da2bba9a3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/NestedPathWrapperExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/NestedPathWrapperExpression.java @@ -70,9 +70,9 @@ class NestedPathWrapperExpression implements SpiExpression { @Override public boolean isSameByPlan(SpiExpression other) { if (other instanceof NestedPathWrapperExpression) { - NestedPathWrapperExpression that = (NestedPathWrapperExpression)other; + NestedPathWrapperExpression that = (NestedPathWrapperExpression) other; return nestedPath.equals(that.nestedPath) - && delegate.isSameByPlan(that.delegate); + && delegate.isSameByPlan(that.delegate); } return false; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/NullExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/NullExpression.java index ce05680c4..7fed6fa76 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/NullExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/NullExpression.java @@ -80,7 +80,7 @@ class NullExpression extends AbstractExpression { NullExpression that = (NullExpression) other; return this.propName.equals(that.propName) - && this.notNull == that.notNull; + && this.notNull == that.notNull; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java b/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java index ee917f830..2b8b142a4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java @@ -68,12 +68,12 @@ class PrepareDocNested { /** * Reorganise the flat list of expressions into a tree grouping expressions by nested path. - * + *

* Returns the new top level list of expressions. */ private List group() { - Map groups = new LinkedHashMap(); + Map groups = new LinkedHashMap<>(); // organise expressions by nestedPath for (int i = 0; i < origSize; i++) { @@ -87,7 +87,7 @@ class PrepareDocNested { group.list.add(expr); } - List newList = new ArrayList(); + List newList = new ArrayList<>(); Collection values = groups.values(); for (Group group : values) { group.addTo(newList); @@ -122,8 +122,8 @@ class PrepareDocNested { String nestedPath = expr.nestedPath(beanDescriptor); if (nestedPath == null) { hasMixedNesting = true; - - } if (nestedPath != null) { + } + if (nestedPath != null) { hasNesting = true; if (firstNestedPath == null) { firstNestedPath = nestedPath; @@ -145,7 +145,7 @@ class PrepareDocNested { final String nestedPath; - final List list = new ArrayList(); + final List list = new ArrayList<>(); Group(String nestedPath) { this.nestedPath = nestedPath; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java index 3632086cf..d0f065596 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java @@ -43,8 +43,8 @@ class RawExpression extends NonPrepareExpression { @Override public void addBindValues(SpiExpressionRequest request) { if (values != null) { - for (int i = 0; i < values.length; i++) { - request.addBindValue(values[i]); + for (Object value : values) { + request.addBindValue(value); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java index c50681faa..ec457e5fc 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java @@ -64,8 +64,8 @@ public class SimpleExpression extends AbstractValueExpression { if (prop.isAssocId()) { Object[] ids = prop.getAssocIdValues((EntityBean) value()); if (ids != null) { - for (int i = 0; i < ids.length; i++) { - request.addBindValue(ids[i]); + for (Object id : ids) { + request.addBindValue(id); } } return; @@ -122,8 +122,7 @@ public class SimpleExpression extends AbstractValueExpression { } SimpleExpression that = (SimpleExpression) other; - return this.propName.equals(that.propName) - && this.type == that.type; + return this.propName.equals(that.propName) && this.type == that.type; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/package.html b/src/main/java/com/avaje/ebeaninternal/server/expression/package.html index b06ccffc1..aa87c6cf1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/package.html @@ -1,36 +1,36 @@ - - Collection objects for lazy loading + + Collection objects for lazy loading Expressions for building WHERE clauses.

-You will most likely use expressions directly off the ExpressionList. + You will most likely use expressions directly off the ExpressionList.

   Query<Order> query = Ebean.createQuery(Order.class)
     .where()
       .like("customer.name","rob%")
       .gt("orderDate",lastWeek);
-    
+
   List<Order> orderList = query.findList();
   ...
 

-In the code above the LIKE and GREATER THAN Expressions are added to the where clause. -The way this works is that where() returns an ExpressionList which has methods on -it to create the standard expressions (EQUAL TO, LIKE etc). + In the code above the LIKE and GREATER THAN Expressions are added to the where clause. + The way this works is that where() returns an ExpressionList which has methods on + it to create the standard expressions (EQUAL TO, LIKE etc).

-I expect most people to add their expressions in this way. The Expr expression factory -object also has the ability to create the standard expressions. + I expect most people to add their expressions in this way. The Expr expression factory + object also has the ability to create the standard expressions.

-You can build your own Expression objects by implementing the Expression interface. + You can build your own Expression objects by implementing the Expression interface.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java index 1eceaf120..b1cd04c17 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java @@ -57,7 +57,7 @@ class EqlAdapter extends EQLBaseListener { } if (whereStack == null) { - whereStack = new ArrayStack>(); + whereStack = new ArrayStack<>(); whereStack.push(query.where()); } // return the current expression list @@ -66,7 +66,7 @@ class EqlAdapter extends EQLBaseListener { private ExpressionList _peekText() { if (textStack == null) { - textStack = new ArrayStack>(); + textStack = new ArrayStack<>(); // empty so push on the queries base expression list textStack.push(query.text()); } @@ -182,7 +182,7 @@ class EqlAdapter extends EQLBaseListener { */ private String trimParenthesis(String text) { text = text.substring(1); - text = text.substring(0, text.length()-1); + text = text.substring(0, text.length() - 1); return text; } @@ -198,25 +198,25 @@ class EqlAdapter extends EQLBaseListener { String path = getLeftHandSidePath(ctx); EqlOperator op = getOperator(ctx); if (op != EqlOperator.BETWEEN) { - throw new IllegalStateException("Expecting BETWEEN operator but got "+op); + throw new IllegalStateException("Expecting BETWEEN operator but got " + op); } - helper.addBetween(path, child(ctx,2), child(ctx,4)); + helper.addBetween(path, child(ctx, 2), child(ctx, 4)); } @Override public void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { checkChildren(ctx, 5); - String rawValue = child(ctx,0); + String rawValue = child(ctx, 0); EqlOperator op = getOperator(ctx); if (op != EqlOperator.BETWEEN) { - throw new IllegalStateException("Expecting BETWEEN operator but got "+op); + throw new IllegalStateException("Expecting BETWEEN operator but got " + op); } - helper.addBetweenProperty(rawValue, child(ctx,2), child(ctx,4)); + helper.addBetweenProperty(rawValue, child(ctx, 2), child(ctx, 4)); } @Override public void enterIn_expression(EQLParser.In_expressionContext ctx) { - this.inValues = new ArrayList(); + this.inValues = new ArrayList<>(); this.inPropertyName = getLeftHandSidePath(ctx); } @@ -308,16 +308,23 @@ class EqlAdapter extends EQLBaseListener { private EqlOperator invert(EqlOperator op) { switch (op) { // no change - case EQ : return EqlOperator.EQ; - case IEQ : return EqlOperator.IEQ; - case NE : return EqlOperator.NE; + case EQ: + return EqlOperator.EQ; + case IEQ: + return EqlOperator.IEQ; + case NE: + return EqlOperator.NE; // invert - case LT : return EqlOperator.GT; - case LTE : return EqlOperator.GTE; - case GT : return EqlOperator.LT; - case GTE : return EqlOperator.LTE; + case LT: + return EqlOperator.GT; + case LTE: + return EqlOperator.GTE; + case GT: + return EqlOperator.LT; + case GTE: + return EqlOperator.LTE; default: - throw new IllegalStateException("Can not invert operator "+op); + throw new IllegalStateException("Can not invert operator " + op); } } @@ -366,7 +373,7 @@ class EqlAdapter extends EQLBaseListener { } private EqlOperator getOperator(ParserRuleContext ctx) { - String operator = child(ctx,1); + String operator = child(ctx, 1); EqlOperator op = operatorMapping.get(operator); if (op == null) { throw new IllegalStateException("No operator found for " + operator); diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java index 1733d132f..41df9bbaa 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java @@ -8,9 +8,9 @@ import java.util.List; class EqlAdapterHelper { - private final EqlAdapter owner; + private final EqlAdapter owner; - public EqlAdapterHelper(EqlAdapter owner) { + public EqlAdapterHelper(EqlAdapter owner) { this.owner = owner; } @@ -49,7 +49,6 @@ class EqlAdapterHelper { peekExprList().between(path, bind(value1), bind(value2)); } - @SuppressWarnings("unchecked") protected void addIn(String path, List inValues) { peekExprList().in(path, inValues); } @@ -117,24 +116,26 @@ class EqlAdapterHelper { return getBindValue(valueType, value); } - private ExpressionList peekExprList() { + private ExpressionList peekExprList() { return owner.peekExprList(); } private Object getBindValue(ValueType valueType, String value) { switch (valueType) { - case BOOL: return Boolean.parseBoolean(value); - case NUMBER: return new BigDecimal(value); - case STRING: return unquote(value); - case NAMED_PARAM: return owner.namedParam(value.substring(1)); + case BOOL: + return Boolean.parseBoolean(value); + case NUMBER: + return new BigDecimal(value); + case STRING: + return unquote(value); + case NAMED_PARAM: + return owner.namedParam(value.substring(1)); default: - throw new IllegalArgumentException("Unhandled valueType "+valueType); + throw new IllegalArgumentException("Unhandled valueType " + valueType); } } private String unquote(String value) { - String raw = value.substring(1, value.length() - 1); - //raw.replaceAll(); - return raw; + return value.substring(1, value.length() - 1); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlParser.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlParser.java index 12b5e7a41..44e06bff3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlParser.java @@ -28,7 +28,7 @@ public class EqlParser { parser.addErrorListener(errorListener); EQLParser.Select_statementContext context = parser.select_statement(); - EqlAdapter adapter = new EqlAdapter(query); + EqlAdapter adapter = new EqlAdapter<>(query); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(adapter, context); diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java index 2e19dd512..8ad872cb0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java @@ -5,7 +5,7 @@ import java.util.Map; class OperatorMapping { - Map map = new HashMap(); + Map map = new HashMap<>(); public OperatorMapping() { map.put("eq", EqlOperator.EQ); diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/ParseFetchConfig.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/ParseFetchConfig.java index db014c6c0..0432345d2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/ParseFetchConfig.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/ParseFetchConfig.java @@ -43,7 +43,7 @@ class ParseFetchConfig { } private static int parseBatchSize(String path) { - path = path.substring(0, path.length()-1); + path = path.substring(0, path.length() - 1); return Integer.parseInt(path); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLBaseListener.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLBaseListener.java index 9c4201e44..e6ab2e11b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLBaseListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLBaseListener.java @@ -11,509 +11,759 @@ import org.antlr.v4.runtime.tree.TerminalNode; * of the available methods. */ public class EQLBaseListener implements EQLListener { - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSelect_statement(EQLParser.Select_statementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSelect_statement(EQLParser.Select_statementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSelect_clause(EQLParser.Select_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSelect_clause(EQLParser.Select_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDistinct(EQLParser.DistinctContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDistinct(EQLParser.DistinctContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_clause(EQLParser.Fetch_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_clause(EQLParser.Fetch_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterWhere_clause(EQLParser.Where_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitWhere_clause(EQLParser.Where_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOrderby_property(EQLParser.Orderby_propertyContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAsc_desc(EQLParser.Asc_descContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAsc_desc(EQLParser.Asc_descContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLimit_clause(EQLParser.Limit_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLimit_clause(EQLParser.Limit_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOffset_clause(EQLParser.Offset_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOffset_clause(EQLParser.Offset_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_path(EQLParser.Fetch_pathContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_path(EQLParser.Fetch_pathContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_property(EQLParser.Fetch_propertyContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_property(EQLParser.Fetch_propertyContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_option(EQLParser.Fetch_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_option(EQLParser.Fetch_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConditional_expression(EQLParser.Conditional_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConditional_expression(EQLParser.Conditional_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConditional_term(EQLParser.Conditional_termContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConditional_term(EQLParser.Conditional_termContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConditional_factor(EQLParser.Conditional_factorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConditional_factor(EQLParser.Conditional_factorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConditional_primary(EQLParser.Conditional_primaryContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConditional_primary(EQLParser.Conditional_primaryContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAny_expression(EQLParser.Any_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAny_expression(EQLParser.Any_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIn_expression(EQLParser.In_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIn_expression(EQLParser.In_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIn_value(EQLParser.In_valueContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIn_value(EQLParser.In_valueContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBetween_expression(EQLParser.Between_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBetween_expression(EQLParser.Between_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLike_expression(EQLParser.Like_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLike_expression(EQLParser.Like_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLike_op(EQLParser.Like_opContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLike_op(EQLParser.Like_opContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterComparison_expression(EQLParser.Comparison_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitComparison_expression(EQLParser.Comparison_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterComparison_operator(EQLParser.Comparison_operatorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitComparison_operator(EQLParser.Comparison_operatorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterValue_expression(EQLParser.Value_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitValue_expression(EQLParser.Value_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLiteral(EQLParser.LiteralContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLiteral(EQLParser.LiteralContext ctx) { } + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterSelect_statement(EQLParser.Select_statementContext ctx) { + } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitTerminal(TerminalNode node) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitErrorNode(ErrorNode node) { } -} \ No newline at end of file + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitSelect_statement(EQLParser.Select_statementContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterSelect_clause(EQLParser.Select_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitSelect_clause(EQLParser.Select_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterDistinct(EQLParser.DistinctContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitDistinct(EQLParser.DistinctContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_clause(EQLParser.Fetch_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_clause(EQLParser.Fetch_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterWhere_clause(EQLParser.Where_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitWhere_clause(EQLParser.Where_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitOrderby_property(EQLParser.Orderby_propertyContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterAsc_desc(EQLParser.Asc_descContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitAsc_desc(EQLParser.Asc_descContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterLimit_clause(EQLParser.Limit_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitLimit_clause(EQLParser.Limit_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterOffset_clause(EQLParser.Offset_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitOffset_clause(EQLParser.Offset_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_path(EQLParser.Fetch_pathContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_path(EQLParser.Fetch_pathContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_property(EQLParser.Fetch_propertyContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_property(EQLParser.Fetch_propertyContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_option(EQLParser.Fetch_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_option(EQLParser.Fetch_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterConditional_expression(EQLParser.Conditional_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitConditional_expression(EQLParser.Conditional_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterConditional_term(EQLParser.Conditional_termContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitConditional_term(EQLParser.Conditional_termContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterConditional_factor(EQLParser.Conditional_factorContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitConditional_factor(EQLParser.Conditional_factorContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterConditional_primary(EQLParser.Conditional_primaryContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitConditional_primary(EQLParser.Conditional_primaryContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterAny_expression(EQLParser.Any_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitAny_expression(EQLParser.Any_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIn_expression(EQLParser.In_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIn_expression(EQLParser.In_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIn_value(EQLParser.In_valueContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIn_value(EQLParser.In_valueContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterBetween_expression(EQLParser.Between_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitBetween_expression(EQLParser.Between_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterLike_expression(EQLParser.Like_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitLike_expression(EQLParser.Like_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterLike_op(EQLParser.Like_opContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitLike_op(EQLParser.Like_opContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterComparison_expression(EQLParser.Comparison_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitComparison_expression(EQLParser.Comparison_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterComparison_operator(EQLParser.Comparison_operatorContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitComparison_operator(EQLParser.Comparison_operatorContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterValue_expression(EQLParser.Value_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitValue_expression(EQLParser.Value_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterLiteral(EQLParser.LiteralContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitLiteral(EQLParser.LiteralContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterEveryRule(ParserRuleContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitEveryRule(ParserRuleContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void visitTerminal(TerminalNode node) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void visitErrorNode(ErrorNode node) { + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLLexer.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLLexer.java index 42b4b904f..6ecbf17d7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLLexer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLLexer.java @@ -1,301 +1,319 @@ // Generated from /home/rob/github/ebean/src/test/resources/EQL.g4 by ANTLR 4.5.3 package com.avaje.ebeaninternal.server.grammer.antlr; -import org.antlr.v4.runtime.Lexer; + import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.LexerATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.misc.*; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class EQLLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); } + static { + RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); + } - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, - T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, - T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, - T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, - T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, INPUT_VARIABLE=58, PATH_VARIABLE=59, - BOOLEAN_LITERAL=60, NUMBER_LITERAL=61, DOUBLE=62, INT=63, ZERO=64, STRING_LITERAL=65, - WS=66; - public static String[] modeNames = { - "DEFAULT_MODE" - }; + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7, T__7 = 8, T__8 = 9, + T__9 = 10, T__10 = 11, T__11 = 12, T__12 = 13, T__13 = 14, T__14 = 15, T__15 = 16, T__16 = 17, + T__17 = 18, T__18 = 19, T__19 = 20, T__20 = 21, T__21 = 22, T__22 = 23, T__23 = 24, + T__24 = 25, T__25 = 26, T__26 = 27, T__27 = 28, T__28 = 29, T__29 = 30, T__30 = 31, + T__31 = 32, T__32 = 33, T__33 = 34, T__34 = 35, T__35 = 36, T__36 = 37, T__37 = 38, + T__38 = 39, T__39 = 40, T__40 = 41, T__41 = 42, T__42 = 43, T__43 = 44, T__44 = 45, + T__45 = 46, T__46 = 47, T__47 = 48, T__48 = 49, T__49 = 50, T__50 = 51, T__51 = 52, + T__52 = 53, T__53 = 54, T__54 = 55, T__55 = 56, T__56 = 57, INPUT_VARIABLE = 58, PATH_VARIABLE = 59, + BOOLEAN_LITERAL = 60, NUMBER_LITERAL = 61, DOUBLE = 62, INT = 63, ZERO = 64, STRING_LITERAL = 65, + WS = 66; + public static String[] modeNames = { + "DEFAULT_MODE" + }; - public static final String[] ruleNames = { - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", - "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", - "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", - "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", - "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", - "T__49", "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", "T__56", - "INPUT_VARIABLE", "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", - "DOUBLE", "INT", "ZERO", "STRING_LITERAL", "WS" - }; + public static final String[] ruleNames = { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", + "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", + "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", + "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", + "T__49", "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", "T__56", + "INPUT_VARIABLE", "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", + "DOUBLE", "INT", "ZERO", "STRING_LITERAL", "WS" + }; - private static final String[] _LITERAL_NAMES = { - null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'", - "','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'", - "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'", - "'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'", - "'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'", - "'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'", - "'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'", - "'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'", - null, null, null, null, null, null, "'0'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE", - "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT", - "ZERO", "STRING_LITERAL", "WS" - }; - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + private static final String[] _LITERAL_NAMES = { + null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'", + "','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'", + "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'", + "'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'", + "'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'", + "'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'", + "'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'", + "'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'", + null, null, null, null, null, null, "'0'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE", + "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT", + "ZERO", "STRING_LITERAL", "WS" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } - @Override + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } - public Vocabulary getVocabulary() { - return VOCABULARY; - } + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } - @Override - public void recover(RecognitionException e) { - throw new RuntimeException("Error in grammer - " + e.getMessage()); - } + @Override + public void recover(RecognitionException e) { + throw new RuntimeException("Error in grammer - " + e.getMessage()); + } - public EQLLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } + public EQLLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); + } - @Override - public String getGrammarFileName() { return "EQL.g4"; } + @Override + public String getGrammarFileName() { + return "EQL.g4"; + } - @Override - public String[] getRuleNames() { return ruleNames; } + @Override + public String[] getRuleNames() { + return ruleNames; + } - @Override - public String getSerializedATN() { return _serializedATN; } + @Override + public String getSerializedATN() { + return _serializedATN; + } - @Override - public String[] getModeNames() { return modeNames; } + @Override + public String[] getModeNames() { + return modeNames; + } - @Override - public ATN getATN() { return _ATN; } + @Override + public ATN getATN() { + return _ATN; + } - public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2D\u0200\b\1\4\2\t"+ - "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ - "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ - "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ - "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ - ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+ - "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ - "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3"+ - "\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6"+ - "\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3"+ - "\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\16"+ - "\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20"+ - "\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\23\3\23\3\23"+ - "\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\26\3\26\3\26"+ - "\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31"+ - "\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34"+ - "\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36"+ - "\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3 \3"+ - " \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\3"+ - "\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%"+ - "\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3"+ - "\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3"+ - ")\3)\3)\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3+\3+\3,\3,\3,\3-\3-\3.\3.\3.\3"+ - "/\3/\3/\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\62\3\62\3\63\3\63\3\63\3"+ - "\64\3\64\3\64\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\67\3\67\3\67\38\38"+ - "\38\39\39\39\3:\3:\3:\3:\3;\3;\3;\7;\u01bb\n;\f;\16;\u01be\13;\3<\3<\7"+ - "<\u01c2\n<\f<\16<\u01c5\13<\3=\3=\3=\3=\3=\3=\3=\3=\3=\5=\u01d0\n=\3>"+ - "\5>\u01d3\n>\3>\3>\5>\u01d7\n>\3>\3>\5>\u01db\n>\3?\6?\u01de\n?\r?\16"+ - "?\u01df\3?\3?\7?\u01e4\n?\f?\16?\u01e7\13?\3@\3@\7@\u01eb\n@\f@\16@\u01ee"+ - "\13@\3A\3A\3B\3B\3B\3B\7B\u01f6\nB\fB\16B\u01f9\13B\3B\3B\3C\3C\3C\3C"+ - "\2\2D\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35"+ - "\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36"+ - ";\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67"+ - "m8o9q:s;u{?}@\177A\u0081B\u0083C\u0085D\3\2\t\5\2C\\aac|\6\2\62;"+ - "C\\aac|\7\2\60\60\62;C\\aac|\3\2\62;\3\2\63;\3\2))\5\2\13\f\17\17\"\""+ - "\u020b\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2"+ - "\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3"+ - "\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2"+ - "\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2"+ - "/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2"+ - "\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2"+ - "G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3"+ - "\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2"+ - "\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2"+ - "m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3"+ - "\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2"+ - "\2\2\2\u0085\3\2\2\2\3\u0087\3\2\2\2\5\u008e\3\2\2\2\7\u0090\3\2\2\2\t"+ - "\u0092\3\2\2\2\13\u009b\3\2\2\2\r\u00a1\3\2\2\2\17\u00a7\3\2\2\2\21\u00aa"+ - "\3\2\2\2\23\u00ac\3\2\2\2\25\u00b2\3\2\2\2\27\u00b8\3\2\2\2\31\u00bd\3"+ - "\2\2\2\33\u00c1\3\2\2\2\35\u00c6\3\2\2\2\37\u00cc\3\2\2\2!\u00d3\3\2\2"+ - "\2#\u00d9\3\2\2\2%\u00db\3\2\2\2\'\u00e1\3\2\2\2)\u00e6\3\2\2\2+\u00e9"+ - "\3\2\2\2-\u00ed\3\2\2\2/\u00f1\3\2\2\2\61\u00f4\3\2\2\2\63\u00fc\3\2\2"+ - "\2\65\u00ff\3\2\2\2\67\u0104\3\2\2\29\u010b\3\2\2\2;\u0115\3\2\2\2=\u011d"+ - "\3\2\2\2?\u0123\3\2\2\2A\u012b\3\2\2\2C\u0136\3\2\2\2E\u013f\3\2\2\2G"+ - "\u0144\3\2\2\2I\u014a\3\2\2\2K\u0153\3\2\2\2M\u015d\3\2\2\2O\u0168\3\2"+ - "\2\2Q\u0174\3\2\2\2S\u017d\3\2\2\2U\u0187\3\2\2\2W\u0189\3\2\2\2Y\u018c"+ - "\3\2\2\2[\u018e\3\2\2\2]\u0191\3\2\2\2_\u0194\3\2\2\2a\u0197\3\2\2\2c"+ - "\u019b\3\2\2\2e\u019d\3\2\2\2g\u01a0\3\2\2\2i\u01a3\3\2\2\2k\u01a6\3\2"+ - "\2\2m\u01aa\3\2\2\2o\u01ad\3\2\2\2q\u01b0\3\2\2\2s\u01b3\3\2\2\2u\u01b7"+ - "\3\2\2\2w\u01bf\3\2\2\2y\u01cf\3\2\2\2{\u01da\3\2\2\2}\u01dd\3\2\2\2\177"+ - "\u01e8\3\2\2\2\u0081\u01ef\3\2\2\2\u0083\u01f1\3\2\2\2\u0085\u01fc\3\2"+ - "\2\2\u0087\u0088\7u\2\2\u0088\u0089\7g\2\2\u0089\u008a\7n\2\2\u008a\u008b"+ - "\7g\2\2\u008b\u008c\7e\2\2\u008c\u008d\7v\2\2\u008d\4\3\2\2\2\u008e\u008f"+ - "\7*\2\2\u008f\6\3\2\2\2\u0090\u0091\7+\2\2\u0091\b\3\2\2\2\u0092\u0093"+ - "\7f\2\2\u0093\u0094\7k\2\2\u0094\u0095\7u\2\2\u0095\u0096\7v\2\2\u0096"+ - "\u0097\7k\2\2\u0097\u0098\7p\2\2\u0098\u0099\7e\2\2\u0099\u009a\7v\2\2"+ - "\u009a\n\3\2\2\2\u009b\u009c\7y\2\2\u009c\u009d\7j\2\2\u009d\u009e\7g"+ - "\2\2\u009e\u009f\7t\2\2\u009f\u00a0\7g\2\2\u00a0\f\3\2\2\2\u00a1\u00a2"+ - "\7q\2\2\u00a2\u00a3\7t\2\2\u00a3\u00a4\7f\2\2\u00a4\u00a5\7g\2\2\u00a5"+ - "\u00a6\7t\2\2\u00a6\16\3\2\2\2\u00a7\u00a8\7d\2\2\u00a8\u00a9\7{\2\2\u00a9"+ - "\20\3\2\2\2\u00aa\u00ab\7.\2\2\u00ab\22\3\2\2\2\u00ac\u00ad\7p\2\2\u00ad"+ - "\u00ae\7w\2\2\u00ae\u00af\7n\2\2\u00af\u00b0\7n\2\2\u00b0\u00b1\7u\2\2"+ - "\u00b1\24\3\2\2\2\u00b2\u00b3\7h\2\2\u00b3\u00b4\7k\2\2\u00b4\u00b5\7"+ - "t\2\2\u00b5\u00b6\7u\2\2\u00b6\u00b7\7v\2\2\u00b7\26\3\2\2\2\u00b8\u00b9"+ - "\7n\2\2\u00b9\u00ba\7c\2\2\u00ba\u00bb\7u\2\2\u00bb\u00bc\7v\2\2\u00bc"+ - "\30\3\2\2\2\u00bd\u00be\7c\2\2\u00be\u00bf\7u\2\2\u00bf\u00c0\7e\2\2\u00c0"+ - "\32\3\2\2\2\u00c1\u00c2\7f\2\2\u00c2\u00c3\7g\2\2\u00c3\u00c4\7u\2\2\u00c4"+ - "\u00c5\7e\2\2\u00c5\34\3\2\2\2\u00c6\u00c7\7n\2\2\u00c7\u00c8\7k\2\2\u00c8"+ - "\u00c9\7o\2\2\u00c9\u00ca\7k\2\2\u00ca\u00cb\7v\2\2\u00cb\36\3\2\2\2\u00cc"+ - "\u00cd\7q\2\2\u00cd\u00ce\7h\2\2\u00ce\u00cf\7h\2\2\u00cf\u00d0\7u\2\2"+ - "\u00d0\u00d1\7g\2\2\u00d1\u00d2\7v\2\2\u00d2 \3\2\2\2\u00d3\u00d4\7h\2"+ - "\2\u00d4\u00d5\7g\2\2\u00d5\u00d6\7v\2\2\u00d6\u00d7\7e\2\2\u00d7\u00d8"+ - "\7j\2\2\u00d8\"\3\2\2\2\u00d9\u00da\7-\2\2\u00da$\3\2\2\2\u00db\u00dc"+ - "\7s\2\2\u00dc\u00dd\7w\2\2\u00dd\u00de\7g\2\2\u00de\u00df\7t\2\2\u00df"+ - "\u00e0\7{\2\2\u00e0&\3\2\2\2\u00e1\u00e2\7n\2\2\u00e2\u00e3\7c\2\2\u00e3"+ - "\u00e4\7|\2\2\u00e4\u00e5\7{\2\2\u00e5(\3\2\2\2\u00e6\u00e7\7q\2\2\u00e7"+ - "\u00e8\7t\2\2\u00e8*\3\2\2\2\u00e9\u00ea\7c\2\2\u00ea\u00eb\7p\2\2\u00eb"+ - "\u00ec\7f\2\2\u00ec,\3\2\2\2\u00ed\u00ee\7p\2\2\u00ee\u00ef\7q\2\2\u00ef"+ - "\u00f0\7v\2\2\u00f0.\3\2\2\2\u00f1\u00f2\7k\2\2\u00f2\u00f3\7p\2\2\u00f3"+ - "\60\3\2\2\2\u00f4\u00f5\7d\2\2\u00f5\u00f6\7g\2\2\u00f6\u00f7\7v\2\2\u00f7"+ - "\u00f8\7y\2\2\u00f8\u00f9\7g\2\2\u00f9\u00fa\7g\2\2\u00fa\u00fb\7p\2\2"+ - "\u00fb\62\3\2\2\2\u00fc\u00fd\7k\2\2\u00fd\u00fe\7u\2\2\u00fe\64\3\2\2"+ - "\2\u00ff\u0100\7p\2\2\u0100\u0101\7w\2\2\u0101\u0102\7n\2\2\u0102\u0103"+ - "\7n\2\2\u0103\66\3\2\2\2\u0104\u0105\7k\2\2\u0105\u0106\7u\2\2\u0106\u0107"+ - "\7P\2\2\u0107\u0108\7w\2\2\u0108\u0109\7n\2\2\u0109\u010a\7n\2\2\u010a"+ - "8\3\2\2\2\u010b\u010c\7k\2\2\u010c\u010d\7u\2\2\u010d\u010e\7P\2\2\u010e"+ - "\u010f\7q\2\2\u010f\u0110\7v\2\2\u0110\u0111\7P\2\2\u0111\u0112\7w\2\2"+ - "\u0112\u0113\7n\2\2\u0113\u0114\7n\2\2\u0114:\3\2\2\2\u0115\u0116\7p\2"+ - "\2\u0116\u0117\7q\2\2\u0117\u0118\7v\2\2\u0118\u0119\7P\2\2\u0119\u011a"+ - "\7w\2\2\u011a\u011b\7n\2\2\u011b\u011c\7n\2\2\u011c<\3\2\2\2\u011d\u011e"+ - "\7g\2\2\u011e\u011f\7o\2\2\u011f\u0120\7r\2\2\u0120\u0121\7v\2\2\u0121"+ - "\u0122\7{\2\2\u0122>\3\2\2\2\u0123\u0124\7k\2\2\u0124\u0125\7u\2\2\u0125"+ - "\u0126\7G\2\2\u0126\u0127\7o\2\2\u0127\u0128\7r\2\2\u0128\u0129\7v\2\2"+ - "\u0129\u012a\7{\2\2\u012a@\3\2\2\2\u012b\u012c\7k\2\2\u012c\u012d\7u\2"+ - "\2\u012d\u012e\7P\2\2\u012e\u012f\7q\2\2\u012f\u0130\7v\2\2\u0130\u0131"+ - "\7G\2\2\u0131\u0132\7o\2\2\u0132\u0133\7r\2\2\u0133\u0134\7v\2\2\u0134"+ - "\u0135\7{\2\2\u0135B\3\2\2\2\u0136\u0137\7p\2\2\u0137\u0138\7q\2\2\u0138"+ - "\u0139\7v\2\2\u0139\u013a\7G\2\2\u013a\u013b\7o\2\2\u013b\u013c\7r\2\2"+ - "\u013c\u013d\7v\2\2\u013d\u013e\7{\2\2\u013eD\3\2\2\2\u013f\u0140\7n\2"+ - "\2\u0140\u0141\7k\2\2\u0141\u0142\7m\2\2\u0142\u0143\7g\2\2\u0143F\3\2"+ - "\2\2\u0144\u0145\7k\2\2\u0145\u0146\7n\2\2\u0146\u0147\7k\2\2\u0147\u0148"+ - "\7m\2\2\u0148\u0149\7g\2\2\u0149H\3\2\2\2\u014a\u014b\7e\2\2\u014b\u014c"+ - "\7q\2\2\u014c\u014d\7p\2\2\u014d\u014e\7v\2\2\u014e\u014f\7c\2\2\u014f"+ - "\u0150\7k\2\2\u0150\u0151\7p\2\2\u0151\u0152\7u\2\2\u0152J\3\2\2\2\u0153"+ - "\u0154\7k\2\2\u0154\u0155\7e\2\2\u0155\u0156\7q\2\2\u0156\u0157\7p\2\2"+ - "\u0157\u0158\7v\2\2\u0158\u0159\7c\2\2\u0159\u015a\7k\2\2\u015a\u015b"+ - "\7p\2\2\u015b\u015c\7u\2\2\u015cL\3\2\2\2\u015d\u015e\7u\2\2\u015e\u015f"+ - "\7v\2\2\u015f\u0160\7c\2\2\u0160\u0161\7t\2\2\u0161\u0162\7v\2\2\u0162"+ - "\u0163\7u\2\2\u0163\u0164\7Y\2\2\u0164\u0165\7k\2\2\u0165\u0166\7v\2\2"+ - "\u0166\u0167\7j\2\2\u0167N\3\2\2\2\u0168\u0169\7k\2\2\u0169\u016a\7u\2"+ - "\2\u016a\u016b\7v\2\2\u016b\u016c\7c\2\2\u016c\u016d\7t\2\2\u016d\u016e"+ - "\7v\2\2\u016e\u016f\7u\2\2\u016f\u0170\7Y\2\2\u0170\u0171\7k\2\2\u0171"+ - "\u0172\7v\2\2\u0172\u0173\7j\2\2\u0173P\3\2\2\2\u0174\u0175\7g\2\2\u0175"+ - "\u0176\7p\2\2\u0176\u0177\7f\2\2\u0177\u0178\7u\2\2\u0178\u0179\7Y\2\2"+ - "\u0179\u017a\7k\2\2\u017a\u017b\7v\2\2\u017b\u017c\7j\2\2\u017cR\3\2\2"+ - "\2\u017d\u017e\7k\2\2\u017e\u017f\7g\2\2\u017f\u0180\7p\2\2\u0180\u0181"+ - "\7f\2\2\u0181\u0182\7u\2\2\u0182\u0183\7Y\2\2\u0183\u0184\7k\2\2\u0184"+ - "\u0185\7v\2\2\u0185\u0186\7j\2\2\u0186T\3\2\2\2\u0187\u0188\7?\2\2\u0188"+ - "V\3\2\2\2\u0189\u018a\7g\2\2\u018a\u018b\7s\2\2\u018bX\3\2\2\2\u018c\u018d"+ - "\7@\2\2\u018dZ\3\2\2\2\u018e\u018f\7i\2\2\u018f\u0190\7v\2\2\u0190\\\3"+ - "\2\2\2\u0191\u0192\7@\2\2\u0192\u0193\7?\2\2\u0193^\3\2\2\2\u0194\u0195"+ - "\7i\2\2\u0195\u0196\7g\2\2\u0196`\3\2\2\2\u0197\u0198\7i\2\2\u0198\u0199"+ - "\7v\2\2\u0199\u019a\7g\2\2\u019ab\3\2\2\2\u019b\u019c\7>\2\2\u019cd\3"+ - "\2\2\2\u019d\u019e\7n\2\2\u019e\u019f\7v\2\2\u019ff\3\2\2\2\u01a0\u01a1"+ - "\7>\2\2\u01a1\u01a2\7?\2\2\u01a2h\3\2\2\2\u01a3\u01a4\7n\2\2\u01a4\u01a5"+ - "\7g\2\2\u01a5j\3\2\2\2\u01a6\u01a7\7n\2\2\u01a7\u01a8\7v\2\2\u01a8\u01a9"+ - "\7g\2\2\u01a9l\3\2\2\2\u01aa\u01ab\7>\2\2\u01ab\u01ac\7@\2\2\u01acn\3"+ - "\2\2\2\u01ad\u01ae\7#\2\2\u01ae\u01af\7?\2\2\u01afp\3\2\2\2\u01b0\u01b1"+ - "\7p\2\2\u01b1\u01b2\7g\2\2\u01b2r\3\2\2\2\u01b3\u01b4\7k\2\2\u01b4\u01b5"+ - "\7g\2\2\u01b5\u01b6\7s\2\2\u01b6t\3\2\2\2\u01b7\u01b8\7<\2\2\u01b8\u01bc"+ - "\t\2\2\2\u01b9\u01bb\t\3\2\2\u01ba\u01b9\3\2\2\2\u01bb\u01be\3\2\2\2\u01bc"+ - "\u01ba\3\2\2\2\u01bc\u01bd\3\2\2\2\u01bdv\3\2\2\2\u01be\u01bc\3\2\2\2"+ - "\u01bf\u01c3\t\2\2\2\u01c0\u01c2\t\4\2\2\u01c1\u01c0\3\2\2\2\u01c2\u01c5"+ - "\3\2\2\2\u01c3\u01c1\3\2\2\2\u01c3\u01c4\3\2\2\2\u01c4x\3\2\2\2\u01c5"+ - "\u01c3\3\2\2\2\u01c6\u01c7\7v\2\2\u01c7\u01c8\7t\2\2\u01c8\u01c9\7w\2"+ - "\2\u01c9\u01d0\7g\2\2\u01ca\u01cb\7h\2\2\u01cb\u01cc\7c\2\2\u01cc\u01cd"+ - "\7n\2\2\u01cd\u01ce\7u\2\2\u01ce\u01d0\7g\2\2\u01cf\u01c6\3\2\2\2\u01cf"+ - "\u01ca\3\2\2\2\u01d0z\3\2\2\2\u01d1\u01d3\7/\2\2\u01d2\u01d1\3\2\2\2\u01d2"+ - "\u01d3\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4\u01db\5}?\2\u01d5\u01d7\7/\2"+ - "\2\u01d6\u01d5\3\2\2\2\u01d6\u01d7\3\2\2\2\u01d7\u01d8\3\2\2\2\u01d8\u01db"+ - "\5\177@\2\u01d9\u01db\5\u0081A\2\u01da\u01d2\3\2\2\2\u01da\u01d6\3\2\2"+ - "\2\u01da\u01d9\3\2\2\2\u01db|\3\2\2\2\u01dc\u01de\t\5\2\2\u01dd\u01dc"+ - "\3\2\2\2\u01de\u01df\3\2\2\2\u01df\u01dd\3\2\2\2\u01df\u01e0\3\2\2\2\u01e0"+ - "\u01e1\3\2\2\2\u01e1\u01e5\7\60\2\2\u01e2\u01e4\t\5\2\2\u01e3\u01e2\3"+ - "\2\2\2\u01e4\u01e7\3\2\2\2\u01e5\u01e3\3\2\2\2\u01e5\u01e6\3\2\2\2\u01e6"+ - "~\3\2\2\2\u01e7\u01e5\3\2\2\2\u01e8\u01ec\t\6\2\2\u01e9\u01eb\t\5\2\2"+ - "\u01ea\u01e9\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed"+ - "\3\2\2\2\u01ed\u0080\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f0\7\62\2\2"+ - "\u01f0\u0082\3\2\2\2\u01f1\u01f7\7)\2\2\u01f2\u01f6\n\7\2\2\u01f3\u01f4"+ - "\7)\2\2\u01f4\u01f6\7)\2\2\u01f5\u01f2\3\2\2\2\u01f5\u01f3\3\2\2\2\u01f6"+ - "\u01f9\3\2\2\2\u01f7\u01f5\3\2\2\2\u01f7\u01f8\3\2\2\2\u01f8\u01fa\3\2"+ - "\2\2\u01f9\u01f7\3\2\2\2\u01fa\u01fb\7)\2\2\u01fb\u0084\3\2\2\2\u01fc"+ - "\u01fd\t\b\2\2\u01fd\u01fe\3\2\2\2\u01fe\u01ff\bC\2\2\u01ff\u0086\3\2"+ - "\2\2\16\2\u01bc\u01c3\u01cf\u01d2\u01d6\u01da\u01df\u01e5\u01ec\u01f5"+ - "\u01f7\3\b\2\2"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file + public static final String _serializedATN = + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2D\u0200\b\1\4\2\t" + + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13" + + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22" + + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31" + + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!" + + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4" + + ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t" + + "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t=" + + "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3" + + "\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6" + + "\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3" + + "\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\16" + + "\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20" + + "\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\23\3\23\3\23" + + "\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\26\3\26\3\26" + + "\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31" + + "\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34" + + "\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36" + + "\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3 \3" + + " \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\3" + + "\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%" + + "\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3" + + "\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3" + + ")\3)\3)\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3+\3+\3,\3,\3,\3-\3-\3.\3.\3.\3" + + "/\3/\3/\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\62\3\62\3\63\3\63\3\63\3" + + "\64\3\64\3\64\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\67\3\67\3\67\38\38" + + "\38\39\39\39\3:\3:\3:\3:\3;\3;\3;\7;\u01bb\n;\f;\16;\u01be\13;\3<\3<\7" + + "<\u01c2\n<\f<\16<\u01c5\13<\3=\3=\3=\3=\3=\3=\3=\3=\3=\5=\u01d0\n=\3>" + + "\5>\u01d3\n>\3>\3>\5>\u01d7\n>\3>\3>\5>\u01db\n>\3?\6?\u01de\n?\r?\16" + + "?\u01df\3?\3?\7?\u01e4\n?\f?\16?\u01e7\13?\3@\3@\7@\u01eb\n@\f@\16@\u01ee" + + "\13@\3A\3A\3B\3B\3B\3B\7B\u01f6\nB\fB\16B\u01f9\13B\3B\3B\3C\3C\3C\3C" + + "\2\2D\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35" + + "\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36" + + ";\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67" + + "m8o9q:s;u{?}@\177A\u0081B\u0083C\u0085D\3\2\t\5\2C\\aac|\6\2\62;" + + "C\\aac|\7\2\60\60\62;C\\aac|\3\2\62;\3\2\63;\3\2))\5\2\13\f\17\17\"\"" + + "\u020b\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2" + + "\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3" + + "\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2" + + "\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2" + + "/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2" + + "\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2" + + "G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3" + + "\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2" + + "\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2" + + "m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3" + + "\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2" + + "\2\2\2\u0085\3\2\2\2\3\u0087\3\2\2\2\5\u008e\3\2\2\2\7\u0090\3\2\2\2\t" + + "\u0092\3\2\2\2\13\u009b\3\2\2\2\r\u00a1\3\2\2\2\17\u00a7\3\2\2\2\21\u00aa" + + "\3\2\2\2\23\u00ac\3\2\2\2\25\u00b2\3\2\2\2\27\u00b8\3\2\2\2\31\u00bd\3" + + "\2\2\2\33\u00c1\3\2\2\2\35\u00c6\3\2\2\2\37\u00cc\3\2\2\2!\u00d3\3\2\2" + + "\2#\u00d9\3\2\2\2%\u00db\3\2\2\2\'\u00e1\3\2\2\2)\u00e6\3\2\2\2+\u00e9" + + "\3\2\2\2-\u00ed\3\2\2\2/\u00f1\3\2\2\2\61\u00f4\3\2\2\2\63\u00fc\3\2\2" + + "\2\65\u00ff\3\2\2\2\67\u0104\3\2\2\29\u010b\3\2\2\2;\u0115\3\2\2\2=\u011d" + + "\3\2\2\2?\u0123\3\2\2\2A\u012b\3\2\2\2C\u0136\3\2\2\2E\u013f\3\2\2\2G" + + "\u0144\3\2\2\2I\u014a\3\2\2\2K\u0153\3\2\2\2M\u015d\3\2\2\2O\u0168\3\2" + + "\2\2Q\u0174\3\2\2\2S\u017d\3\2\2\2U\u0187\3\2\2\2W\u0189\3\2\2\2Y\u018c" + + "\3\2\2\2[\u018e\3\2\2\2]\u0191\3\2\2\2_\u0194\3\2\2\2a\u0197\3\2\2\2c" + + "\u019b\3\2\2\2e\u019d\3\2\2\2g\u01a0\3\2\2\2i\u01a3\3\2\2\2k\u01a6\3\2" + + "\2\2m\u01aa\3\2\2\2o\u01ad\3\2\2\2q\u01b0\3\2\2\2s\u01b3\3\2\2\2u\u01b7" + + "\3\2\2\2w\u01bf\3\2\2\2y\u01cf\3\2\2\2{\u01da\3\2\2\2}\u01dd\3\2\2\2\177" + + "\u01e8\3\2\2\2\u0081\u01ef\3\2\2\2\u0083\u01f1\3\2\2\2\u0085\u01fc\3\2" + + "\2\2\u0087\u0088\7u\2\2\u0088\u0089\7g\2\2\u0089\u008a\7n\2\2\u008a\u008b" + + "\7g\2\2\u008b\u008c\7e\2\2\u008c\u008d\7v\2\2\u008d\4\3\2\2\2\u008e\u008f" + + "\7*\2\2\u008f\6\3\2\2\2\u0090\u0091\7+\2\2\u0091\b\3\2\2\2\u0092\u0093" + + "\7f\2\2\u0093\u0094\7k\2\2\u0094\u0095\7u\2\2\u0095\u0096\7v\2\2\u0096" + + "\u0097\7k\2\2\u0097\u0098\7p\2\2\u0098\u0099\7e\2\2\u0099\u009a\7v\2\2" + + "\u009a\n\3\2\2\2\u009b\u009c\7y\2\2\u009c\u009d\7j\2\2\u009d\u009e\7g" + + "\2\2\u009e\u009f\7t\2\2\u009f\u00a0\7g\2\2\u00a0\f\3\2\2\2\u00a1\u00a2" + + "\7q\2\2\u00a2\u00a3\7t\2\2\u00a3\u00a4\7f\2\2\u00a4\u00a5\7g\2\2\u00a5" + + "\u00a6\7t\2\2\u00a6\16\3\2\2\2\u00a7\u00a8\7d\2\2\u00a8\u00a9\7{\2\2\u00a9" + + "\20\3\2\2\2\u00aa\u00ab\7.\2\2\u00ab\22\3\2\2\2\u00ac\u00ad\7p\2\2\u00ad" + + "\u00ae\7w\2\2\u00ae\u00af\7n\2\2\u00af\u00b0\7n\2\2\u00b0\u00b1\7u\2\2" + + "\u00b1\24\3\2\2\2\u00b2\u00b3\7h\2\2\u00b3\u00b4\7k\2\2\u00b4\u00b5\7" + + "t\2\2\u00b5\u00b6\7u\2\2\u00b6\u00b7\7v\2\2\u00b7\26\3\2\2\2\u00b8\u00b9" + + "\7n\2\2\u00b9\u00ba\7c\2\2\u00ba\u00bb\7u\2\2\u00bb\u00bc\7v\2\2\u00bc" + + "\30\3\2\2\2\u00bd\u00be\7c\2\2\u00be\u00bf\7u\2\2\u00bf\u00c0\7e\2\2\u00c0" + + "\32\3\2\2\2\u00c1\u00c2\7f\2\2\u00c2\u00c3\7g\2\2\u00c3\u00c4\7u\2\2\u00c4" + + "\u00c5\7e\2\2\u00c5\34\3\2\2\2\u00c6\u00c7\7n\2\2\u00c7\u00c8\7k\2\2\u00c8" + + "\u00c9\7o\2\2\u00c9\u00ca\7k\2\2\u00ca\u00cb\7v\2\2\u00cb\36\3\2\2\2\u00cc" + + "\u00cd\7q\2\2\u00cd\u00ce\7h\2\2\u00ce\u00cf\7h\2\2\u00cf\u00d0\7u\2\2" + + "\u00d0\u00d1\7g\2\2\u00d1\u00d2\7v\2\2\u00d2 \3\2\2\2\u00d3\u00d4\7h\2" + + "\2\u00d4\u00d5\7g\2\2\u00d5\u00d6\7v\2\2\u00d6\u00d7\7e\2\2\u00d7\u00d8" + + "\7j\2\2\u00d8\"\3\2\2\2\u00d9\u00da\7-\2\2\u00da$\3\2\2\2\u00db\u00dc" + + "\7s\2\2\u00dc\u00dd\7w\2\2\u00dd\u00de\7g\2\2\u00de\u00df\7t\2\2\u00df" + + "\u00e0\7{\2\2\u00e0&\3\2\2\2\u00e1\u00e2\7n\2\2\u00e2\u00e3\7c\2\2\u00e3" + + "\u00e4\7|\2\2\u00e4\u00e5\7{\2\2\u00e5(\3\2\2\2\u00e6\u00e7\7q\2\2\u00e7" + + "\u00e8\7t\2\2\u00e8*\3\2\2\2\u00e9\u00ea\7c\2\2\u00ea\u00eb\7p\2\2\u00eb" + + "\u00ec\7f\2\2\u00ec,\3\2\2\2\u00ed\u00ee\7p\2\2\u00ee\u00ef\7q\2\2\u00ef" + + "\u00f0\7v\2\2\u00f0.\3\2\2\2\u00f1\u00f2\7k\2\2\u00f2\u00f3\7p\2\2\u00f3" + + "\60\3\2\2\2\u00f4\u00f5\7d\2\2\u00f5\u00f6\7g\2\2\u00f6\u00f7\7v\2\2\u00f7" + + "\u00f8\7y\2\2\u00f8\u00f9\7g\2\2\u00f9\u00fa\7g\2\2\u00fa\u00fb\7p\2\2" + + "\u00fb\62\3\2\2\2\u00fc\u00fd\7k\2\2\u00fd\u00fe\7u\2\2\u00fe\64\3\2\2" + + "\2\u00ff\u0100\7p\2\2\u0100\u0101\7w\2\2\u0101\u0102\7n\2\2\u0102\u0103" + + "\7n\2\2\u0103\66\3\2\2\2\u0104\u0105\7k\2\2\u0105\u0106\7u\2\2\u0106\u0107" + + "\7P\2\2\u0107\u0108\7w\2\2\u0108\u0109\7n\2\2\u0109\u010a\7n\2\2\u010a" + + "8\3\2\2\2\u010b\u010c\7k\2\2\u010c\u010d\7u\2\2\u010d\u010e\7P\2\2\u010e" + + "\u010f\7q\2\2\u010f\u0110\7v\2\2\u0110\u0111\7P\2\2\u0111\u0112\7w\2\2" + + "\u0112\u0113\7n\2\2\u0113\u0114\7n\2\2\u0114:\3\2\2\2\u0115\u0116\7p\2" + + "\2\u0116\u0117\7q\2\2\u0117\u0118\7v\2\2\u0118\u0119\7P\2\2\u0119\u011a" + + "\7w\2\2\u011a\u011b\7n\2\2\u011b\u011c\7n\2\2\u011c<\3\2\2\2\u011d\u011e" + + "\7g\2\2\u011e\u011f\7o\2\2\u011f\u0120\7r\2\2\u0120\u0121\7v\2\2\u0121" + + "\u0122\7{\2\2\u0122>\3\2\2\2\u0123\u0124\7k\2\2\u0124\u0125\7u\2\2\u0125" + + "\u0126\7G\2\2\u0126\u0127\7o\2\2\u0127\u0128\7r\2\2\u0128\u0129\7v\2\2" + + "\u0129\u012a\7{\2\2\u012a@\3\2\2\2\u012b\u012c\7k\2\2\u012c\u012d\7u\2" + + "\2\u012d\u012e\7P\2\2\u012e\u012f\7q\2\2\u012f\u0130\7v\2\2\u0130\u0131" + + "\7G\2\2\u0131\u0132\7o\2\2\u0132\u0133\7r\2\2\u0133\u0134\7v\2\2\u0134" + + "\u0135\7{\2\2\u0135B\3\2\2\2\u0136\u0137\7p\2\2\u0137\u0138\7q\2\2\u0138" + + "\u0139\7v\2\2\u0139\u013a\7G\2\2\u013a\u013b\7o\2\2\u013b\u013c\7r\2\2" + + "\u013c\u013d\7v\2\2\u013d\u013e\7{\2\2\u013eD\3\2\2\2\u013f\u0140\7n\2" + + "\2\u0140\u0141\7k\2\2\u0141\u0142\7m\2\2\u0142\u0143\7g\2\2\u0143F\3\2" + + "\2\2\u0144\u0145\7k\2\2\u0145\u0146\7n\2\2\u0146\u0147\7k\2\2\u0147\u0148" + + "\7m\2\2\u0148\u0149\7g\2\2\u0149H\3\2\2\2\u014a\u014b\7e\2\2\u014b\u014c" + + "\7q\2\2\u014c\u014d\7p\2\2\u014d\u014e\7v\2\2\u014e\u014f\7c\2\2\u014f" + + "\u0150\7k\2\2\u0150\u0151\7p\2\2\u0151\u0152\7u\2\2\u0152J\3\2\2\2\u0153" + + "\u0154\7k\2\2\u0154\u0155\7e\2\2\u0155\u0156\7q\2\2\u0156\u0157\7p\2\2" + + "\u0157\u0158\7v\2\2\u0158\u0159\7c\2\2\u0159\u015a\7k\2\2\u015a\u015b" + + "\7p\2\2\u015b\u015c\7u\2\2\u015cL\3\2\2\2\u015d\u015e\7u\2\2\u015e\u015f" + + "\7v\2\2\u015f\u0160\7c\2\2\u0160\u0161\7t\2\2\u0161\u0162\7v\2\2\u0162" + + "\u0163\7u\2\2\u0163\u0164\7Y\2\2\u0164\u0165\7k\2\2\u0165\u0166\7v\2\2" + + "\u0166\u0167\7j\2\2\u0167N\3\2\2\2\u0168\u0169\7k\2\2\u0169\u016a\7u\2" + + "\2\u016a\u016b\7v\2\2\u016b\u016c\7c\2\2\u016c\u016d\7t\2\2\u016d\u016e" + + "\7v\2\2\u016e\u016f\7u\2\2\u016f\u0170\7Y\2\2\u0170\u0171\7k\2\2\u0171" + + "\u0172\7v\2\2\u0172\u0173\7j\2\2\u0173P\3\2\2\2\u0174\u0175\7g\2\2\u0175" + + "\u0176\7p\2\2\u0176\u0177\7f\2\2\u0177\u0178\7u\2\2\u0178\u0179\7Y\2\2" + + "\u0179\u017a\7k\2\2\u017a\u017b\7v\2\2\u017b\u017c\7j\2\2\u017cR\3\2\2" + + "\2\u017d\u017e\7k\2\2\u017e\u017f\7g\2\2\u017f\u0180\7p\2\2\u0180\u0181" + + "\7f\2\2\u0181\u0182\7u\2\2\u0182\u0183\7Y\2\2\u0183\u0184\7k\2\2\u0184" + + "\u0185\7v\2\2\u0185\u0186\7j\2\2\u0186T\3\2\2\2\u0187\u0188\7?\2\2\u0188" + + "V\3\2\2\2\u0189\u018a\7g\2\2\u018a\u018b\7s\2\2\u018bX\3\2\2\2\u018c\u018d" + + "\7@\2\2\u018dZ\3\2\2\2\u018e\u018f\7i\2\2\u018f\u0190\7v\2\2\u0190\\\3" + + "\2\2\2\u0191\u0192\7@\2\2\u0192\u0193\7?\2\2\u0193^\3\2\2\2\u0194\u0195" + + "\7i\2\2\u0195\u0196\7g\2\2\u0196`\3\2\2\2\u0197\u0198\7i\2\2\u0198\u0199" + + "\7v\2\2\u0199\u019a\7g\2\2\u019ab\3\2\2\2\u019b\u019c\7>\2\2\u019cd\3" + + "\2\2\2\u019d\u019e\7n\2\2\u019e\u019f\7v\2\2\u019ff\3\2\2\2\u01a0\u01a1" + + "\7>\2\2\u01a1\u01a2\7?\2\2\u01a2h\3\2\2\2\u01a3\u01a4\7n\2\2\u01a4\u01a5" + + "\7g\2\2\u01a5j\3\2\2\2\u01a6\u01a7\7n\2\2\u01a7\u01a8\7v\2\2\u01a8\u01a9" + + "\7g\2\2\u01a9l\3\2\2\2\u01aa\u01ab\7>\2\2\u01ab\u01ac\7@\2\2\u01acn\3" + + "\2\2\2\u01ad\u01ae\7#\2\2\u01ae\u01af\7?\2\2\u01afp\3\2\2\2\u01b0\u01b1" + + "\7p\2\2\u01b1\u01b2\7g\2\2\u01b2r\3\2\2\2\u01b3\u01b4\7k\2\2\u01b4\u01b5" + + "\7g\2\2\u01b5\u01b6\7s\2\2\u01b6t\3\2\2\2\u01b7\u01b8\7<\2\2\u01b8\u01bc" + + "\t\2\2\2\u01b9\u01bb\t\3\2\2\u01ba\u01b9\3\2\2\2\u01bb\u01be\3\2\2\2\u01bc" + + "\u01ba\3\2\2\2\u01bc\u01bd\3\2\2\2\u01bdv\3\2\2\2\u01be\u01bc\3\2\2\2" + + "\u01bf\u01c3\t\2\2\2\u01c0\u01c2\t\4\2\2\u01c1\u01c0\3\2\2\2\u01c2\u01c5" + + "\3\2\2\2\u01c3\u01c1\3\2\2\2\u01c3\u01c4\3\2\2\2\u01c4x\3\2\2\2\u01c5" + + "\u01c3\3\2\2\2\u01c6\u01c7\7v\2\2\u01c7\u01c8\7t\2\2\u01c8\u01c9\7w\2" + + "\2\u01c9\u01d0\7g\2\2\u01ca\u01cb\7h\2\2\u01cb\u01cc\7c\2\2\u01cc\u01cd" + + "\7n\2\2\u01cd\u01ce\7u\2\2\u01ce\u01d0\7g\2\2\u01cf\u01c6\3\2\2\2\u01cf" + + "\u01ca\3\2\2\2\u01d0z\3\2\2\2\u01d1\u01d3\7/\2\2\u01d2\u01d1\3\2\2\2\u01d2" + + "\u01d3\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4\u01db\5}?\2\u01d5\u01d7\7/\2" + + "\2\u01d6\u01d5\3\2\2\2\u01d6\u01d7\3\2\2\2\u01d7\u01d8\3\2\2\2\u01d8\u01db" + + "\5\177@\2\u01d9\u01db\5\u0081A\2\u01da\u01d2\3\2\2\2\u01da\u01d6\3\2\2" + + "\2\u01da\u01d9\3\2\2\2\u01db|\3\2\2\2\u01dc\u01de\t\5\2\2\u01dd\u01dc" + + "\3\2\2\2\u01de\u01df\3\2\2\2\u01df\u01dd\3\2\2\2\u01df\u01e0\3\2\2\2\u01e0" + + "\u01e1\3\2\2\2\u01e1\u01e5\7\60\2\2\u01e2\u01e4\t\5\2\2\u01e3\u01e2\3" + + "\2\2\2\u01e4\u01e7\3\2\2\2\u01e5\u01e3\3\2\2\2\u01e5\u01e6\3\2\2\2\u01e6" + + "~\3\2\2\2\u01e7\u01e5\3\2\2\2\u01e8\u01ec\t\6\2\2\u01e9\u01eb\t\5\2\2" + + "\u01ea\u01e9\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed" + + "\3\2\2\2\u01ed\u0080\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f0\7\62\2\2" + + "\u01f0\u0082\3\2\2\2\u01f1\u01f7\7)\2\2\u01f2\u01f6\n\7\2\2\u01f3\u01f4" + + "\7)\2\2\u01f4\u01f6\7)\2\2\u01f5\u01f2\3\2\2\2\u01f5\u01f3\3\2\2\2\u01f6" + + "\u01f9\3\2\2\2\u01f7\u01f5\3\2\2\2\u01f7\u01f8\3\2\2\2\u01f8\u01fa\3\2" + + "\2\2\u01f9\u01f7\3\2\2\2\u01fa\u01fb\7)\2\2\u01fb\u0084\3\2\2\2\u01fc" + + "\u01fd\t\b\2\2\u01fd\u01fe\3\2\2\2\u01fe\u01ff\bC\2\2\u01ff\u0086\3\2" + + "\2\2\16\2\u01bc\u01c3\u01cf\u01d2\u01d6\u01da\u01df\u01e5\u01ec\u01f5" + + "\u01f7\3\b\2\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLListener.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLListener.java index 8a340bf8a..3a6e3d4ec 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLListener.java @@ -1,5 +1,6 @@ // Generated from /home/rob/github/ebean/src/test/resources/EQL.g4 by ANTLR 4.5.3 package com.avaje.ebeaninternal.server.grammer.antlr; + import org.antlr.v4.runtime.tree.ParseTreeListener; /** @@ -7,404 +8,563 @@ import org.antlr.v4.runtime.tree.ParseTreeListener; * {@link EQLParser}. */ public interface EQLListener extends ParseTreeListener { - /** - * Enter a parse tree produced by {@link EQLParser#select_statement}. - * @param ctx the parse tree - */ - void enterSelect_statement(EQLParser.Select_statementContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#select_statement}. - * @param ctx the parse tree - */ - void exitSelect_statement(EQLParser.Select_statementContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#select_clause}. - * @param ctx the parse tree - */ - void enterSelect_clause(EQLParser.Select_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#select_clause}. - * @param ctx the parse tree - */ - void exitSelect_clause(EQLParser.Select_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#distinct}. - * @param ctx the parse tree - */ - void enterDistinct(EQLParser.DistinctContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#distinct}. - * @param ctx the parse tree - */ - void exitDistinct(EQLParser.DistinctContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_clause}. - * @param ctx the parse tree - */ - void enterFetch_clause(EQLParser.Fetch_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_clause}. - * @param ctx the parse tree - */ - void exitFetch_clause(EQLParser.Fetch_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#where_clause}. - * @param ctx the parse tree - */ - void enterWhere_clause(EQLParser.Where_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#where_clause}. - * @param ctx the parse tree - */ - void exitWhere_clause(EQLParser.Where_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#orderby_clause}. - * @param ctx the parse tree - */ - void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#orderby_clause}. - * @param ctx the parse tree - */ - void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#orderby_property}. - * @param ctx the parse tree - */ - void enterOrderby_property(EQLParser.Orderby_propertyContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#orderby_property}. - * @param ctx the parse tree - */ - void exitOrderby_property(EQLParser.Orderby_propertyContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#nulls_firstlast}. - * @param ctx the parse tree - */ - void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#nulls_firstlast}. - * @param ctx the parse tree - */ - void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#asc_desc}. - * @param ctx the parse tree - */ - void enterAsc_desc(EQLParser.Asc_descContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#asc_desc}. - * @param ctx the parse tree - */ - void exitAsc_desc(EQLParser.Asc_descContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#limit_clause}. - * @param ctx the parse tree - */ - void enterLimit_clause(EQLParser.Limit_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#limit_clause}. - * @param ctx the parse tree - */ - void exitLimit_clause(EQLParser.Limit_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#offset_clause}. - * @param ctx the parse tree - */ - void enterOffset_clause(EQLParser.Offset_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#offset_clause}. - * @param ctx the parse tree - */ - void exitOffset_clause(EQLParser.Offset_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_path}. - * @param ctx the parse tree - */ - void enterFetch_path(EQLParser.Fetch_pathContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_path}. - * @param ctx the parse tree - */ - void exitFetch_path(EQLParser.Fetch_pathContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_property_set}. - * @param ctx the parse tree - */ - void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_property_set}. - * @param ctx the parse tree - */ - void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_property_group}. - * @param ctx the parse tree - */ - void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_property_group}. - * @param ctx the parse tree - */ - void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_property}. - * @param ctx the parse tree - */ - void enterFetch_property(EQLParser.Fetch_propertyContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_property}. - * @param ctx the parse tree - */ - void exitFetch_property(EQLParser.Fetch_propertyContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_query_hint}. - * @param ctx the parse tree - */ - void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_query_hint}. - * @param ctx the parse tree - */ - void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_lazy_hint}. - * @param ctx the parse tree - */ - void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_lazy_hint}. - * @param ctx the parse tree - */ - void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_option}. - * @param ctx the parse tree - */ - void enterFetch_option(EQLParser.Fetch_optionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_option}. - * @param ctx the parse tree - */ - void exitFetch_option(EQLParser.Fetch_optionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_query_option}. - * @param ctx the parse tree - */ - void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_query_option}. - * @param ctx the parse tree - */ - void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_lazy_option}. - * @param ctx the parse tree - */ - void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_lazy_option}. - * @param ctx the parse tree - */ - void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_batch_size}. - * @param ctx the parse tree - */ - void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_batch_size}. - * @param ctx the parse tree - */ - void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#conditional_expression}. - * @param ctx the parse tree - */ - void enterConditional_expression(EQLParser.Conditional_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#conditional_expression}. - * @param ctx the parse tree - */ - void exitConditional_expression(EQLParser.Conditional_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#conditional_term}. - * @param ctx the parse tree - */ - void enterConditional_term(EQLParser.Conditional_termContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#conditional_term}. - * @param ctx the parse tree - */ - void exitConditional_term(EQLParser.Conditional_termContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#conditional_factor}. - * @param ctx the parse tree - */ - void enterConditional_factor(EQLParser.Conditional_factorContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#conditional_factor}. - * @param ctx the parse tree - */ - void exitConditional_factor(EQLParser.Conditional_factorContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#conditional_primary}. - * @param ctx the parse tree - */ - void enterConditional_primary(EQLParser.Conditional_primaryContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#conditional_primary}. - * @param ctx the parse tree - */ - void exitConditional_primary(EQLParser.Conditional_primaryContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#any_expression}. - * @param ctx the parse tree - */ - void enterAny_expression(EQLParser.Any_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#any_expression}. - * @param ctx the parse tree - */ - void exitAny_expression(EQLParser.Any_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#in_expression}. - * @param ctx the parse tree - */ - void enterIn_expression(EQLParser.In_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#in_expression}. - * @param ctx the parse tree - */ - void exitIn_expression(EQLParser.In_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#in_value}. - * @param ctx the parse tree - */ - void enterIn_value(EQLParser.In_valueContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#in_value}. - * @param ctx the parse tree - */ - void exitIn_value(EQLParser.In_valueContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#between_expression}. - * @param ctx the parse tree - */ - void enterBetween_expression(EQLParser.Between_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#between_expression}. - * @param ctx the parse tree - */ - void exitBetween_expression(EQLParser.Between_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#propertyBetween_expression}. - * @param ctx the parse tree - */ - void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#propertyBetween_expression}. - * @param ctx the parse tree - */ - void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#isNull_expression}. - * @param ctx the parse tree - */ - void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#isNull_expression}. - * @param ctx the parse tree - */ - void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#isNotNull_expression}. - * @param ctx the parse tree - */ - void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#isNotNull_expression}. - * @param ctx the parse tree - */ - void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#isEmpty_expression}. - * @param ctx the parse tree - */ - void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#isEmpty_expression}. - * @param ctx the parse tree - */ - void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#isNotEmpty_expression}. - * @param ctx the parse tree - */ - void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#isNotEmpty_expression}. - * @param ctx the parse tree - */ - void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#like_expression}. - * @param ctx the parse tree - */ - void enterLike_expression(EQLParser.Like_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#like_expression}. - * @param ctx the parse tree - */ - void exitLike_expression(EQLParser.Like_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#like_op}. - * @param ctx the parse tree - */ - void enterLike_op(EQLParser.Like_opContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#like_op}. - * @param ctx the parse tree - */ - void exitLike_op(EQLParser.Like_opContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#comparison_expression}. - * @param ctx the parse tree - */ - void enterComparison_expression(EQLParser.Comparison_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#comparison_expression}. - * @param ctx the parse tree - */ - void exitComparison_expression(EQLParser.Comparison_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#comparison_operator}. - * @param ctx the parse tree - */ - void enterComparison_operator(EQLParser.Comparison_operatorContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#comparison_operator}. - * @param ctx the parse tree - */ - void exitComparison_operator(EQLParser.Comparison_operatorContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#value_expression}. - * @param ctx the parse tree - */ - void enterValue_expression(EQLParser.Value_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#value_expression}. - * @param ctx the parse tree - */ - void exitValue_expression(EQLParser.Value_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#literal}. - * @param ctx the parse tree - */ - void enterLiteral(EQLParser.LiteralContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#literal}. - * @param ctx the parse tree - */ - void exitLiteral(EQLParser.LiteralContext ctx); -} \ No newline at end of file + /** + * Enter a parse tree produced by {@link EQLParser#select_statement}. + * + * @param ctx the parse tree + */ + void enterSelect_statement(EQLParser.Select_statementContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#select_statement}. + * + * @param ctx the parse tree + */ + void exitSelect_statement(EQLParser.Select_statementContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#select_clause}. + * + * @param ctx the parse tree + */ + void enterSelect_clause(EQLParser.Select_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#select_clause}. + * + * @param ctx the parse tree + */ + void exitSelect_clause(EQLParser.Select_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#distinct}. + * + * @param ctx the parse tree + */ + void enterDistinct(EQLParser.DistinctContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#distinct}. + * + * @param ctx the parse tree + */ + void exitDistinct(EQLParser.DistinctContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_clause}. + * + * @param ctx the parse tree + */ + void enterFetch_clause(EQLParser.Fetch_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_clause}. + * + * @param ctx the parse tree + */ + void exitFetch_clause(EQLParser.Fetch_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#where_clause}. + * + * @param ctx the parse tree + */ + void enterWhere_clause(EQLParser.Where_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#where_clause}. + * + * @param ctx the parse tree + */ + void exitWhere_clause(EQLParser.Where_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#orderby_clause}. + * + * @param ctx the parse tree + */ + void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#orderby_clause}. + * + * @param ctx the parse tree + */ + void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#orderby_property}. + * + * @param ctx the parse tree + */ + void enterOrderby_property(EQLParser.Orderby_propertyContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#orderby_property}. + * + * @param ctx the parse tree + */ + void exitOrderby_property(EQLParser.Orderby_propertyContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#nulls_firstlast}. + * + * @param ctx the parse tree + */ + void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#nulls_firstlast}. + * + * @param ctx the parse tree + */ + void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#asc_desc}. + * + * @param ctx the parse tree + */ + void enterAsc_desc(EQLParser.Asc_descContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#asc_desc}. + * + * @param ctx the parse tree + */ + void exitAsc_desc(EQLParser.Asc_descContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#limit_clause}. + * + * @param ctx the parse tree + */ + void enterLimit_clause(EQLParser.Limit_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#limit_clause}. + * + * @param ctx the parse tree + */ + void exitLimit_clause(EQLParser.Limit_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#offset_clause}. + * + * @param ctx the parse tree + */ + void enterOffset_clause(EQLParser.Offset_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#offset_clause}. + * + * @param ctx the parse tree + */ + void exitOffset_clause(EQLParser.Offset_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_path}. + * + * @param ctx the parse tree + */ + void enterFetch_path(EQLParser.Fetch_pathContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_path}. + * + * @param ctx the parse tree + */ + void exitFetch_path(EQLParser.Fetch_pathContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_property_set}. + * + * @param ctx the parse tree + */ + void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_property_set}. + * + * @param ctx the parse tree + */ + void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_property_group}. + * + * @param ctx the parse tree + */ + void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_property_group}. + * + * @param ctx the parse tree + */ + void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_property}. + * + * @param ctx the parse tree + */ + void enterFetch_property(EQLParser.Fetch_propertyContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_property}. + * + * @param ctx the parse tree + */ + void exitFetch_property(EQLParser.Fetch_propertyContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_query_hint}. + * + * @param ctx the parse tree + */ + void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_query_hint}. + * + * @param ctx the parse tree + */ + void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_lazy_hint}. + * + * @param ctx the parse tree + */ + void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_lazy_hint}. + * + * @param ctx the parse tree + */ + void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_option}. + * + * @param ctx the parse tree + */ + void enterFetch_option(EQLParser.Fetch_optionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_option}. + * + * @param ctx the parse tree + */ + void exitFetch_option(EQLParser.Fetch_optionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_query_option}. + * + * @param ctx the parse tree + */ + void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_query_option}. + * + * @param ctx the parse tree + */ + void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_lazy_option}. + * + * @param ctx the parse tree + */ + void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_lazy_option}. + * + * @param ctx the parse tree + */ + void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_batch_size}. + * + * @param ctx the parse tree + */ + void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_batch_size}. + * + * @param ctx the parse tree + */ + void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#conditional_expression}. + * + * @param ctx the parse tree + */ + void enterConditional_expression(EQLParser.Conditional_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#conditional_expression}. + * + * @param ctx the parse tree + */ + void exitConditional_expression(EQLParser.Conditional_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#conditional_term}. + * + * @param ctx the parse tree + */ + void enterConditional_term(EQLParser.Conditional_termContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#conditional_term}. + * + * @param ctx the parse tree + */ + void exitConditional_term(EQLParser.Conditional_termContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#conditional_factor}. + * + * @param ctx the parse tree + */ + void enterConditional_factor(EQLParser.Conditional_factorContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#conditional_factor}. + * + * @param ctx the parse tree + */ + void exitConditional_factor(EQLParser.Conditional_factorContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#conditional_primary}. + * + * @param ctx the parse tree + */ + void enterConditional_primary(EQLParser.Conditional_primaryContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#conditional_primary}. + * + * @param ctx the parse tree + */ + void exitConditional_primary(EQLParser.Conditional_primaryContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#any_expression}. + * + * @param ctx the parse tree + */ + void enterAny_expression(EQLParser.Any_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#any_expression}. + * + * @param ctx the parse tree + */ + void exitAny_expression(EQLParser.Any_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#in_expression}. + * + * @param ctx the parse tree + */ + void enterIn_expression(EQLParser.In_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#in_expression}. + * + * @param ctx the parse tree + */ + void exitIn_expression(EQLParser.In_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#in_value}. + * + * @param ctx the parse tree + */ + void enterIn_value(EQLParser.In_valueContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#in_value}. + * + * @param ctx the parse tree + */ + void exitIn_value(EQLParser.In_valueContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#between_expression}. + * + * @param ctx the parse tree + */ + void enterBetween_expression(EQLParser.Between_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#between_expression}. + * + * @param ctx the parse tree + */ + void exitBetween_expression(EQLParser.Between_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#propertyBetween_expression}. + * + * @param ctx the parse tree + */ + void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#propertyBetween_expression}. + * + * @param ctx the parse tree + */ + void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#isNull_expression}. + * + * @param ctx the parse tree + */ + void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#isNull_expression}. + * + * @param ctx the parse tree + */ + void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#isNotNull_expression}. + * + * @param ctx the parse tree + */ + void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#isNotNull_expression}. + * + * @param ctx the parse tree + */ + void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#isEmpty_expression}. + * + * @param ctx the parse tree + */ + void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#isEmpty_expression}. + * + * @param ctx the parse tree + */ + void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#isNotEmpty_expression}. + * + * @param ctx the parse tree + */ + void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#isNotEmpty_expression}. + * + * @param ctx the parse tree + */ + void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#like_expression}. + * + * @param ctx the parse tree + */ + void enterLike_expression(EQLParser.Like_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#like_expression}. + * + * @param ctx the parse tree + */ + void exitLike_expression(EQLParser.Like_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#like_op}. + * + * @param ctx the parse tree + */ + void enterLike_op(EQLParser.Like_opContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#like_op}. + * + * @param ctx the parse tree + */ + void exitLike_op(EQLParser.Like_opContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#comparison_expression}. + * + * @param ctx the parse tree + */ + void enterComparison_expression(EQLParser.Comparison_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#comparison_expression}. + * + * @param ctx the parse tree + */ + void exitComparison_expression(EQLParser.Comparison_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#comparison_operator}. + * + * @param ctx the parse tree + */ + void enterComparison_operator(EQLParser.Comparison_operatorContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#comparison_operator}. + * + * @param ctx the parse tree + */ + void exitComparison_operator(EQLParser.Comparison_operatorContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#value_expression}. + * + * @param ctx the parse tree + */ + void enterValue_expression(EQLParser.Value_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#value_expression}. + * + * @param ctx the parse tree + */ + void exitValue_expression(EQLParser.Value_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#literal}. + * + * @param ctx the parse tree + */ + void enterLiteral(EQLParser.LiteralContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#literal}. + * + * @param ctx the parse tree + */ + void exitLiteral(EQLParser.LiteralContext ctx); +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLParser.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLParser.java index a2f63fc6f..3bf7eb517 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLParser.java @@ -1,124 +1,145 @@ // Generated from /home/rob/github/ebean/src/test/resources/EQL.g4 by ANTLR 4.5.3 package com.avaje.ebeaninternal.server.grammer.antlr; -import org.antlr.v4.runtime.atn.*; + +import org.antlr.v4.runtime.NoViableAltException; +import org.antlr.v4.runtime.Parser; +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.ParserATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.misc.*; -import org.antlr.v4.runtime.tree.*; +import org.antlr.v4.runtime.tree.ParseTreeListener; +import org.antlr.v4.runtime.tree.TerminalNode; + import java.util.List; -import java.util.Iterator; -import java.util.ArrayList; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class EQLParser extends Parser { - static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); } + static { + RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); + } - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, - T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, - T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, - T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, - T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, INPUT_VARIABLE=58, PATH_VARIABLE=59, - BOOLEAN_LITERAL=60, NUMBER_LITERAL=61, DOUBLE=62, INT=63, ZERO=64, STRING_LITERAL=65, - WS=66; - public static final int - RULE_select_statement = 0, RULE_select_clause = 1, RULE_distinct = 2, - RULE_fetch_clause = 3, RULE_where_clause = 4, RULE_orderby_clause = 5, - RULE_orderby_property = 6, RULE_nulls_firstlast = 7, RULE_asc_desc = 8, - RULE_limit_clause = 9, RULE_offset_clause = 10, RULE_fetch_path = 11, - RULE_fetch_property_set = 12, RULE_fetch_property_group = 13, RULE_fetch_property = 14, - RULE_fetch_query_hint = 15, RULE_fetch_lazy_hint = 16, RULE_fetch_option = 17, - RULE_fetch_query_option = 18, RULE_fetch_lazy_option = 19, RULE_fetch_batch_size = 20, - RULE_conditional_expression = 21, RULE_conditional_term = 22, RULE_conditional_factor = 23, - RULE_conditional_primary = 24, RULE_any_expression = 25, RULE_in_expression = 26, - RULE_in_value = 27, RULE_between_expression = 28, RULE_propertyBetween_expression = 29, - RULE_isNull_expression = 30, RULE_isNotNull_expression = 31, RULE_isEmpty_expression = 32, - RULE_isNotEmpty_expression = 33, RULE_like_expression = 34, RULE_like_op = 35, - RULE_comparison_expression = 36, RULE_comparison_operator = 37, RULE_value_expression = 38, - RULE_literal = 39; - public static final String[] ruleNames = { - "select_statement", "select_clause", "distinct", "fetch_clause", "where_clause", - "orderby_clause", "orderby_property", "nulls_firstlast", "asc_desc", "limit_clause", - "offset_clause", "fetch_path", "fetch_property_set", "fetch_property_group", - "fetch_property", "fetch_query_hint", "fetch_lazy_hint", "fetch_option", - "fetch_query_option", "fetch_lazy_option", "fetch_batch_size", "conditional_expression", - "conditional_term", "conditional_factor", "conditional_primary", "any_expression", - "in_expression", "in_value", "between_expression", "propertyBetween_expression", - "isNull_expression", "isNotNull_expression", "isEmpty_expression", "isNotEmpty_expression", - "like_expression", "like_op", "comparison_expression", "comparison_operator", - "value_expression", "literal" - }; + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7, T__7 = 8, T__8 = 9, + T__9 = 10, T__10 = 11, T__11 = 12, T__12 = 13, T__13 = 14, T__14 = 15, T__15 = 16, T__16 = 17, + T__17 = 18, T__18 = 19, T__19 = 20, T__20 = 21, T__21 = 22, T__22 = 23, T__23 = 24, + T__24 = 25, T__25 = 26, T__26 = 27, T__27 = 28, T__28 = 29, T__29 = 30, T__30 = 31, + T__31 = 32, T__32 = 33, T__33 = 34, T__34 = 35, T__35 = 36, T__36 = 37, T__37 = 38, + T__38 = 39, T__39 = 40, T__40 = 41, T__41 = 42, T__42 = 43, T__43 = 44, T__44 = 45, + T__45 = 46, T__46 = 47, T__47 = 48, T__48 = 49, T__49 = 50, T__50 = 51, T__51 = 52, + T__52 = 53, T__53 = 54, T__54 = 55, T__55 = 56, T__56 = 57, INPUT_VARIABLE = 58, PATH_VARIABLE = 59, + BOOLEAN_LITERAL = 60, NUMBER_LITERAL = 61, DOUBLE = 62, INT = 63, ZERO = 64, STRING_LITERAL = 65, + WS = 66; + public static final int + RULE_select_statement = 0, RULE_select_clause = 1, RULE_distinct = 2, + RULE_fetch_clause = 3, RULE_where_clause = 4, RULE_orderby_clause = 5, + RULE_orderby_property = 6, RULE_nulls_firstlast = 7, RULE_asc_desc = 8, + RULE_limit_clause = 9, RULE_offset_clause = 10, RULE_fetch_path = 11, + RULE_fetch_property_set = 12, RULE_fetch_property_group = 13, RULE_fetch_property = 14, + RULE_fetch_query_hint = 15, RULE_fetch_lazy_hint = 16, RULE_fetch_option = 17, + RULE_fetch_query_option = 18, RULE_fetch_lazy_option = 19, RULE_fetch_batch_size = 20, + RULE_conditional_expression = 21, RULE_conditional_term = 22, RULE_conditional_factor = 23, + RULE_conditional_primary = 24, RULE_any_expression = 25, RULE_in_expression = 26, + RULE_in_value = 27, RULE_between_expression = 28, RULE_propertyBetween_expression = 29, + RULE_isNull_expression = 30, RULE_isNotNull_expression = 31, RULE_isEmpty_expression = 32, + RULE_isNotEmpty_expression = 33, RULE_like_expression = 34, RULE_like_op = 35, + RULE_comparison_expression = 36, RULE_comparison_operator = 37, RULE_value_expression = 38, + RULE_literal = 39; + public static final String[] ruleNames = { + "select_statement", "select_clause", "distinct", "fetch_clause", "where_clause", + "orderby_clause", "orderby_property", "nulls_firstlast", "asc_desc", "limit_clause", + "offset_clause", "fetch_path", "fetch_property_set", "fetch_property_group", + "fetch_property", "fetch_query_hint", "fetch_lazy_hint", "fetch_option", + "fetch_query_option", "fetch_lazy_option", "fetch_batch_size", "conditional_expression", + "conditional_term", "conditional_factor", "conditional_primary", "any_expression", + "in_expression", "in_value", "between_expression", "propertyBetween_expression", + "isNull_expression", "isNotNull_expression", "isEmpty_expression", "isNotEmpty_expression", + "like_expression", "like_op", "comparison_expression", "comparison_operator", + "value_expression", "literal" + }; - private static final String[] _LITERAL_NAMES = { - null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'", - "','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'", - "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'", - "'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'", - "'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'", - "'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'", - "'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'", - "'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'", - null, null, null, null, null, null, "'0'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE", - "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT", - "ZERO", "STRING_LITERAL", "WS" - }; - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + private static final String[] _LITERAL_NAMES = { + null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'", + "','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'", + "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'", + "'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'", + "'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'", + "'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'", + "'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'", + "'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'", + null, null, null, null, null, null, "'0'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE", + "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT", + "ZERO", "STRING_LITERAL", "WS" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } - @Override + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } - public Vocabulary getVocabulary() { - return VOCABULARY; - } + @Override - @Override - public String getGrammarFileName() { return "EQL.g4"; } + public Vocabulary getVocabulary() { + return VOCABULARY; + } - @Override - public String[] getRuleNames() { return ruleNames; } + @Override + public String getGrammarFileName() { + return "EQL.g4"; + } - @Override - public String getSerializedATN() { return _serializedATN; } + @Override + public String[] getRuleNames() { + return ruleNames; + } - @Override - public ATN getATN() { return _ATN; } + @Override + public String getSerializedATN() { + return _serializedATN; + } + + @Override + public ATN getATN() { + return _ATN; + } // @Override @@ -126,2354 +147,2633 @@ public class EQLParser extends Parser { // throw new RuntimeException("Error in grammer - " + e.getMessage()); // } - public EQLParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - public static class Select_statementContext extends ParserRuleContext { - public Select_clauseContext select_clause() { - return getRuleContext(Select_clauseContext.class,0); - } - public List fetch_clause() { - return getRuleContexts(Fetch_clauseContext.class); - } - public Fetch_clauseContext fetch_clause(int i) { - return getRuleContext(Fetch_clauseContext.class,i); - } - public Where_clauseContext where_clause() { - return getRuleContext(Where_clauseContext.class,0); - } - public Orderby_clauseContext orderby_clause() { - return getRuleContext(Orderby_clauseContext.class,0); - } - public Limit_clauseContext limit_clause() { - return getRuleContext(Limit_clauseContext.class,0); - } - public Select_statementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_select_statement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterSelect_statement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitSelect_statement(this); - } - } - - public final Select_statementContext select_statement() throws RecognitionException { - Select_statementContext _localctx = new Select_statementContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_select_statement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(81); - _la = _input.LA(1); - if (_la==T__0) { - { - setState(80); - select_clause(); - } - } - - setState(86); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__15) { - { - { - setState(83); - fetch_clause(); - } - } - setState(88); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(90); - _la = _input.LA(1); - if (_la==T__4) { - { - setState(89); - where_clause(); - } - } - - setState(93); - _la = _input.LA(1); - if (_la==T__5) { - { - setState(92); - orderby_clause(); - } - } - - setState(96); - _la = _input.LA(1); - if (_la==T__13) { - { - setState(95); - limit_clause(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Select_clauseContext extends ParserRuleContext { - public Fetch_property_groupContext fetch_property_group() { - return getRuleContext(Fetch_property_groupContext.class,0); - } - public DistinctContext distinct() { - return getRuleContext(DistinctContext.class,0); - } - public Select_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_select_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterSelect_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitSelect_clause(this); - } - } - - public final Select_clauseContext select_clause() throws RecognitionException { - Select_clauseContext _localctx = new Select_clauseContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_select_clause); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(98); - match(T__0); - setState(100); - _la = _input.LA(1); - if (_la==T__3) { - { - setState(99); - distinct(); - } - } - - setState(102); - match(T__1); - setState(103); - fetch_property_group(); - setState(104); - match(T__2); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class DistinctContext extends ParserRuleContext { - public DistinctContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_distinct; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterDistinct(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitDistinct(this); - } - } - - public final DistinctContext distinct() throws RecognitionException { - DistinctContext _localctx = new DistinctContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_distinct); - try { - enterOuterAlt(_localctx, 1); - { - setState(106); - match(T__3); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_clauseContext extends ParserRuleContext { - public Fetch_pathContext fetch_path() { - return getRuleContext(Fetch_pathContext.class,0); - } - public Fetch_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_clause(this); - } - } - - public final Fetch_clauseContext fetch_clause() throws RecognitionException { - Fetch_clauseContext _localctx = new Fetch_clauseContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_fetch_clause); - try { - enterOuterAlt(_localctx, 1); - { - setState(108); - fetch_path(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Where_clauseContext extends ParserRuleContext { - public Conditional_expressionContext conditional_expression() { - return getRuleContext(Conditional_expressionContext.class,0); - } - public Where_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_where_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterWhere_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitWhere_clause(this); - } - } - - public final Where_clauseContext where_clause() throws RecognitionException { - Where_clauseContext _localctx = new Where_clauseContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_where_clause); - try { - enterOuterAlt(_localctx, 1); - { - setState(110); - match(T__4); - setState(111); - conditional_expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Orderby_clauseContext extends ParserRuleContext { - public List orderby_property() { - return getRuleContexts(Orderby_propertyContext.class); - } - public Orderby_propertyContext orderby_property(int i) { - return getRuleContext(Orderby_propertyContext.class,i); - } - public Orderby_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_orderby_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterOrderby_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitOrderby_clause(this); - } - } - - public final Orderby_clauseContext orderby_clause() throws RecognitionException { - Orderby_clauseContext _localctx = new Orderby_clauseContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_orderby_clause); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(113); - match(T__5); - setState(114); - match(T__6); - setState(115); - orderby_property(); - setState(120); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__7) { - { - { - setState(116); - match(T__7); - setState(117); - orderby_property(); - } - } - setState(122); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Orderby_propertyContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Asc_descContext asc_desc() { - return getRuleContext(Asc_descContext.class,0); - } - public Nulls_firstlastContext nulls_firstlast() { - return getRuleContext(Nulls_firstlastContext.class,0); - } - public Orderby_propertyContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_orderby_property; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterOrderby_property(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitOrderby_property(this); - } - } - - public final Orderby_propertyContext orderby_property() throws RecognitionException { - Orderby_propertyContext _localctx = new Orderby_propertyContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_orderby_property); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(123); - match(PATH_VARIABLE); - setState(125); - _la = _input.LA(1); - if (_la==T__11 || _la==T__12) { - { - setState(124); - asc_desc(); - } - } - - setState(128); - _la = _input.LA(1); - if (_la==T__8) { - { - setState(127); - nulls_firstlast(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Nulls_firstlastContext extends ParserRuleContext { - public Nulls_firstlastContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nulls_firstlast; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterNulls_firstlast(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitNulls_firstlast(this); - } - } - - public final Nulls_firstlastContext nulls_firstlast() throws RecognitionException { - Nulls_firstlastContext _localctx = new Nulls_firstlastContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_nulls_firstlast); - try { - setState(134); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,9,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(130); - match(T__8); - setState(131); - match(T__9); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(132); - match(T__8); - setState(133); - match(T__10); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Asc_descContext extends ParserRuleContext { - public Asc_descContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_asc_desc; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterAsc_desc(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitAsc_desc(this); - } - } - - public final Asc_descContext asc_desc() throws RecognitionException { - Asc_descContext _localctx = new Asc_descContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_asc_desc); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(136); - _la = _input.LA(1); - if ( !(_la==T__11 || _la==T__12) ) { - _errHandler.recoverInline(this); - } else { - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Limit_clauseContext extends ParserRuleContext { - public TerminalNode NUMBER_LITERAL() { return getToken(EQLParser.NUMBER_LITERAL, 0); } - public Offset_clauseContext offset_clause() { - return getRuleContext(Offset_clauseContext.class,0); - } - public Limit_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_limit_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterLimit_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitLimit_clause(this); - } - } - - public final Limit_clauseContext limit_clause() throws RecognitionException { - Limit_clauseContext _localctx = new Limit_clauseContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_limit_clause); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(138); - match(T__13); - setState(139); - match(NUMBER_LITERAL); - setState(141); - _la = _input.LA(1); - if (_la==T__14) { - { - setState(140); - offset_clause(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Offset_clauseContext extends ParserRuleContext { - public TerminalNode NUMBER_LITERAL() { return getToken(EQLParser.NUMBER_LITERAL, 0); } - public Offset_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_offset_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterOffset_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitOffset_clause(this); - } - } - - public final Offset_clauseContext offset_clause() throws RecognitionException { - Offset_clauseContext _localctx = new Offset_clauseContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_offset_clause); - try { - enterOuterAlt(_localctx, 1); - { - setState(143); - match(T__14); - setState(144); - match(NUMBER_LITERAL); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_pathContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Fetch_optionContext fetch_option() { - return getRuleContext(Fetch_optionContext.class,0); - } - public Fetch_property_setContext fetch_property_set() { - return getRuleContext(Fetch_property_setContext.class,0); - } - public Fetch_pathContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_path; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_path(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_path(this); - } - } - - public final Fetch_pathContext fetch_path() throws RecognitionException { - Fetch_pathContext _localctx = new Fetch_pathContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_fetch_path); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(146); - match(T__15); - setState(148); - _la = _input.LA(1); - if (_la==T__17 || _la==T__18) { - { - setState(147); - fetch_option(); - } - } - - setState(150); - match(PATH_VARIABLE); - setState(152); - _la = _input.LA(1); - if (_la==T__1) { - { - setState(151); - fetch_property_set(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_property_setContext extends ParserRuleContext { - public Fetch_property_groupContext fetch_property_group() { - return getRuleContext(Fetch_property_groupContext.class,0); - } - public Fetch_property_setContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_property_set; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_property_set(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_property_set(this); - } - } - - public final Fetch_property_setContext fetch_property_set() throws RecognitionException { - Fetch_property_setContext _localctx = new Fetch_property_setContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_fetch_property_set); - try { - enterOuterAlt(_localctx, 1); - { - setState(154); - match(T__1); - setState(155); - fetch_property_group(); - setState(156); - match(T__2); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_property_groupContext extends ParserRuleContext { - public List fetch_property() { - return getRuleContexts(Fetch_propertyContext.class); - } - public Fetch_propertyContext fetch_property(int i) { - return getRuleContext(Fetch_propertyContext.class,i); - } - public Fetch_property_groupContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_property_group; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_property_group(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_property_group(this); - } - } - - public final Fetch_property_groupContext fetch_property_group() throws RecognitionException { - Fetch_property_groupContext _localctx = new Fetch_property_groupContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_fetch_property_group); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(158); - fetch_property(); - setState(163); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__7) { - { - { - setState(159); - match(T__7); - setState(160); - fetch_property(); - } - } - setState(165); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_propertyContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Fetch_query_hintContext fetch_query_hint() { - return getRuleContext(Fetch_query_hintContext.class,0); - } - public Fetch_lazy_hintContext fetch_lazy_hint() { - return getRuleContext(Fetch_lazy_hintContext.class,0); - } - public Fetch_propertyContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_property; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_property(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_property(this); - } - } - - public final Fetch_propertyContext fetch_property() throws RecognitionException { - Fetch_propertyContext _localctx = new Fetch_propertyContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_fetch_property); - try { - setState(169); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(166); - match(PATH_VARIABLE); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(167); - fetch_query_hint(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(168); - fetch_lazy_hint(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_query_hintContext extends ParserRuleContext { - public Fetch_query_optionContext fetch_query_option() { - return getRuleContext(Fetch_query_optionContext.class,0); - } - public Fetch_query_hintContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_query_hint; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_query_hint(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_query_hint(this); - } - } - - public final Fetch_query_hintContext fetch_query_hint() throws RecognitionException { - Fetch_query_hintContext _localctx = new Fetch_query_hintContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_fetch_query_hint); - try { - enterOuterAlt(_localctx, 1); - { - setState(171); - match(T__16); - setState(172); - fetch_query_option(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_lazy_hintContext extends ParserRuleContext { - public Fetch_lazy_optionContext fetch_lazy_option() { - return getRuleContext(Fetch_lazy_optionContext.class,0); - } - public Fetch_lazy_hintContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_lazy_hint; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_lazy_hint(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_lazy_hint(this); - } - } - - public final Fetch_lazy_hintContext fetch_lazy_hint() throws RecognitionException { - Fetch_lazy_hintContext _localctx = new Fetch_lazy_hintContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_fetch_lazy_hint); - try { - enterOuterAlt(_localctx, 1); - { - setState(174); - match(T__16); - setState(175); - fetch_lazy_option(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_optionContext extends ParserRuleContext { - public Fetch_query_optionContext fetch_query_option() { - return getRuleContext(Fetch_query_optionContext.class,0); - } - public Fetch_lazy_optionContext fetch_lazy_option() { - return getRuleContext(Fetch_lazy_optionContext.class,0); - } - public Fetch_optionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_option; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_option(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_option(this); - } - } - - public final Fetch_optionContext fetch_option() throws RecognitionException { - Fetch_optionContext _localctx = new Fetch_optionContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_fetch_option); - try { - setState(179); - switch (_input.LA(1)) { - case T__17: - enterOuterAlt(_localctx, 1); - { - setState(177); - fetch_query_option(); - } - break; - case T__18: - enterOuterAlt(_localctx, 2); - { - setState(178); - fetch_lazy_option(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_query_optionContext extends ParserRuleContext { - public Fetch_batch_sizeContext fetch_batch_size() { - return getRuleContext(Fetch_batch_sizeContext.class,0); - } - public Fetch_query_optionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_query_option; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_query_option(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_query_option(this); - } - } - - public final Fetch_query_optionContext fetch_query_option() throws RecognitionException { - Fetch_query_optionContext _localctx = new Fetch_query_optionContext(_ctx, getState()); - enterRule(_localctx, 36, RULE_fetch_query_option); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(181); - match(T__17); - setState(183); - _la = _input.LA(1); - if (_la==T__1) { - { - setState(182); - fetch_batch_size(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_lazy_optionContext extends ParserRuleContext { - public Fetch_batch_sizeContext fetch_batch_size() { - return getRuleContext(Fetch_batch_sizeContext.class,0); - } - public Fetch_lazy_optionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_lazy_option; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_lazy_option(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_lazy_option(this); - } - } - - public final Fetch_lazy_optionContext fetch_lazy_option() throws RecognitionException { - Fetch_lazy_optionContext _localctx = new Fetch_lazy_optionContext(_ctx, getState()); - enterRule(_localctx, 38, RULE_fetch_lazy_option); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(185); - match(T__18); - setState(187); - _la = _input.LA(1); - if (_la==T__1) { - { - setState(186); - fetch_batch_size(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_batch_sizeContext extends ParserRuleContext { - public TerminalNode NUMBER_LITERAL() { return getToken(EQLParser.NUMBER_LITERAL, 0); } - public Fetch_batch_sizeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_batch_size; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_batch_size(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_batch_size(this); - } - } - - public final Fetch_batch_sizeContext fetch_batch_size() throws RecognitionException { - Fetch_batch_sizeContext _localctx = new Fetch_batch_sizeContext(_ctx, getState()); - enterRule(_localctx, 40, RULE_fetch_batch_size); - try { - enterOuterAlt(_localctx, 1); - { - setState(189); - match(T__1); - setState(190); - match(NUMBER_LITERAL); - setState(191); - match(T__2); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Conditional_expressionContext extends ParserRuleContext { - public List conditional_term() { - return getRuleContexts(Conditional_termContext.class); - } - public Conditional_termContext conditional_term(int i) { - return getRuleContext(Conditional_termContext.class,i); - } - public Conditional_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_conditional_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterConditional_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitConditional_expression(this); - } - } - - public final Conditional_expressionContext conditional_expression() throws RecognitionException { - Conditional_expressionContext _localctx = new Conditional_expressionContext(_ctx, getState()); - enterRule(_localctx, 42, RULE_conditional_expression); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(193); - conditional_term(); - setState(198); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__19) { - { - { - setState(194); - match(T__19); - setState(195); - conditional_term(); - } - } - setState(200); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Conditional_termContext extends ParserRuleContext { - public List conditional_factor() { - return getRuleContexts(Conditional_factorContext.class); - } - public Conditional_factorContext conditional_factor(int i) { - return getRuleContext(Conditional_factorContext.class,i); - } - public Conditional_termContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_conditional_term; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterConditional_term(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitConditional_term(this); - } - } - - public final Conditional_termContext conditional_term() throws RecognitionException { - Conditional_termContext _localctx = new Conditional_termContext(_ctx, getState()); - enterRule(_localctx, 44, RULE_conditional_term); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(201); - conditional_factor(); - setState(206); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__20) { - { - { - setState(202); - match(T__20); - setState(203); - conditional_factor(); - } - } - setState(208); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Conditional_factorContext extends ParserRuleContext { - public Conditional_primaryContext conditional_primary() { - return getRuleContext(Conditional_primaryContext.class,0); - } - public Conditional_factorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_conditional_factor; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterConditional_factor(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitConditional_factor(this); - } - } - - public final Conditional_factorContext conditional_factor() throws RecognitionException { - Conditional_factorContext _localctx = new Conditional_factorContext(_ctx, getState()); - enterRule(_localctx, 46, RULE_conditional_factor); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(210); - _la = _input.LA(1); - if (_la==T__21) { - { - setState(209); - match(T__21); - } - } - - setState(212); - conditional_primary(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Conditional_primaryContext extends ParserRuleContext { - public Any_expressionContext any_expression() { - return getRuleContext(Any_expressionContext.class,0); - } - public Conditional_expressionContext conditional_expression() { - return getRuleContext(Conditional_expressionContext.class,0); - } - public Conditional_primaryContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_conditional_primary; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterConditional_primary(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitConditional_primary(this); - } - } - - public final Conditional_primaryContext conditional_primary() throws RecognitionException { - Conditional_primaryContext _localctx = new Conditional_primaryContext(_ctx, getState()); - enterRule(_localctx, 48, RULE_conditional_primary); - try { - setState(219); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(214); - any_expression(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(215); - match(T__1); - setState(216); - conditional_expression(); - setState(217); - match(T__2); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Any_expressionContext extends ParserRuleContext { - public Comparison_expressionContext comparison_expression() { - return getRuleContext(Comparison_expressionContext.class,0); - } - public Like_expressionContext like_expression() { - return getRuleContext(Like_expressionContext.class,0); - } - public Between_expressionContext between_expression() { - return getRuleContext(Between_expressionContext.class,0); - } - public PropertyBetween_expressionContext propertyBetween_expression() { - return getRuleContext(PropertyBetween_expressionContext.class,0); - } - public In_expressionContext in_expression() { - return getRuleContext(In_expressionContext.class,0); - } - public IsNull_expressionContext isNull_expression() { - return getRuleContext(IsNull_expressionContext.class,0); - } - public IsNotNull_expressionContext isNotNull_expression() { - return getRuleContext(IsNotNull_expressionContext.class,0); - } - public IsEmpty_expressionContext isEmpty_expression() { - return getRuleContext(IsEmpty_expressionContext.class,0); - } - public IsNotEmpty_expressionContext isNotEmpty_expression() { - return getRuleContext(IsNotEmpty_expressionContext.class,0); - } - public Any_expressionContext any_expression() { - return getRuleContext(Any_expressionContext.class,0); - } - public Any_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_any_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterAny_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitAny_expression(this); - } - } - - public final Any_expressionContext any_expression() throws RecognitionException { - Any_expressionContext _localctx = new Any_expressionContext(_ctx, getState()); - enterRule(_localctx, 50, RULE_any_expression); - try { - setState(234); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(221); - comparison_expression(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(222); - like_expression(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(223); - between_expression(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(224); - propertyBetween_expression(); - } - break; - case 5: - enterOuterAlt(_localctx, 5); - { - setState(225); - in_expression(); - } - break; - case 6: - enterOuterAlt(_localctx, 6); - { - setState(226); - isNull_expression(); - } - break; - case 7: - enterOuterAlt(_localctx, 7); - { - setState(227); - isNotNull_expression(); - } - break; - case 8: - enterOuterAlt(_localctx, 8); - { - setState(228); - isEmpty_expression(); - } - break; - case 9: - enterOuterAlt(_localctx, 9); - { - setState(229); - isNotEmpty_expression(); - } - break; - case 10: - enterOuterAlt(_localctx, 10); - { - setState(230); - match(T__1); - setState(231); - any_expression(); - setState(232); - match(T__2); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class In_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public In_valueContext in_value() { - return getRuleContext(In_valueContext.class,0); - } - public In_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_in_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIn_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIn_expression(this); - } - } - - public final In_expressionContext in_expression() throws RecognitionException { - In_expressionContext _localctx = new In_expressionContext(_ctx, getState()); - enterRule(_localctx, 52, RULE_in_expression); - try { - enterOuterAlt(_localctx, 1); - { - setState(236); - match(PATH_VARIABLE); - setState(237); - match(T__22); - setState(238); - in_value(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class In_valueContext extends ParserRuleContext { - public TerminalNode INPUT_VARIABLE() { return getToken(EQLParser.INPUT_VARIABLE, 0); } - public List value_expression() { - return getRuleContexts(Value_expressionContext.class); - } - public Value_expressionContext value_expression(int i) { - return getRuleContext(Value_expressionContext.class,i); - } - public In_valueContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_in_value; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIn_value(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIn_value(this); - } - } - - public final In_valueContext in_value() throws RecognitionException { - In_valueContext _localctx = new In_valueContext(_ctx, getState()); - enterRule(_localctx, 54, RULE_in_value); - int _la; - try { - setState(252); - switch (_input.LA(1)) { - case INPUT_VARIABLE: - enterOuterAlt(_localctx, 1); - { - setState(240); - match(INPUT_VARIABLE); - } - break; - case T__1: - enterOuterAlt(_localctx, 2); - { - setState(241); - match(T__1); - setState(242); - value_expression(); - setState(247); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__7) { - { - { - setState(243); - match(T__7); - setState(244); - value_expression(); - } - } - setState(249); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(250); - match(T__2); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Between_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public List value_expression() { - return getRuleContexts(Value_expressionContext.class); - } - public Value_expressionContext value_expression(int i) { - return getRuleContext(Value_expressionContext.class,i); - } - public Between_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_between_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterBetween_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitBetween_expression(this); - } - } - - public final Between_expressionContext between_expression() throws RecognitionException { - Between_expressionContext _localctx = new Between_expressionContext(_ctx, getState()); - enterRule(_localctx, 56, RULE_between_expression); - try { - enterOuterAlt(_localctx, 1); - { - setState(254); - match(PATH_VARIABLE); - setState(255); - match(T__23); - setState(256); - value_expression(); - setState(257); - match(T__20); - setState(258); - value_expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class PropertyBetween_expressionContext extends ParserRuleContext { - public Value_expressionContext value_expression() { - return getRuleContext(Value_expressionContext.class,0); - } - public List PATH_VARIABLE() { return getTokens(EQLParser.PATH_VARIABLE); } - public TerminalNode PATH_VARIABLE(int i) { - return getToken(EQLParser.PATH_VARIABLE, i); - } - public PropertyBetween_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_propertyBetween_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterPropertyBetween_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitPropertyBetween_expression(this); - } - } - - public final PropertyBetween_expressionContext propertyBetween_expression() throws RecognitionException { - PropertyBetween_expressionContext _localctx = new PropertyBetween_expressionContext(_ctx, getState()); - enterRule(_localctx, 58, RULE_propertyBetween_expression); - try { - enterOuterAlt(_localctx, 1); - { - setState(260); - value_expression(); - setState(261); - match(T__23); - setState(262); - match(PATH_VARIABLE); - setState(263); - match(T__20); - setState(264); - match(PATH_VARIABLE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class IsNull_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public IsNull_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_isNull_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIsNull_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIsNull_expression(this); - } - } - - public final IsNull_expressionContext isNull_expression() throws RecognitionException { - IsNull_expressionContext _localctx = new IsNull_expressionContext(_ctx, getState()); - enterRule(_localctx, 60, RULE_isNull_expression); - try { - setState(271); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(266); - match(PATH_VARIABLE); - setState(267); - match(T__24); - setState(268); - match(T__25); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(269); - match(PATH_VARIABLE); - setState(270); - match(T__26); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class IsNotNull_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public IsNotNull_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_isNotNull_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIsNotNull_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIsNotNull_expression(this); - } - } - - public final IsNotNull_expressionContext isNotNull_expression() throws RecognitionException { - IsNotNull_expressionContext _localctx = new IsNotNull_expressionContext(_ctx, getState()); - enterRule(_localctx, 62, RULE_isNotNull_expression); - try { - setState(281); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,26,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(273); - match(PATH_VARIABLE); - setState(274); - match(T__24); - setState(275); - match(T__21); - setState(276); - match(T__25); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(277); - match(PATH_VARIABLE); - setState(278); - match(T__27); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(279); - match(PATH_VARIABLE); - setState(280); - match(T__28); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class IsEmpty_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public IsEmpty_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_isEmpty_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIsEmpty_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIsEmpty_expression(this); - } - } - - public final IsEmpty_expressionContext isEmpty_expression() throws RecognitionException { - IsEmpty_expressionContext _localctx = new IsEmpty_expressionContext(_ctx, getState()); - enterRule(_localctx, 64, RULE_isEmpty_expression); - try { - setState(288); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,27,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(283); - match(PATH_VARIABLE); - setState(284); - match(T__24); - setState(285); - match(T__29); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(286); - match(PATH_VARIABLE); - setState(287); - match(T__30); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class IsNotEmpty_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public IsNotEmpty_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_isNotEmpty_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIsNotEmpty_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIsNotEmpty_expression(this); - } - } - - public final IsNotEmpty_expressionContext isNotEmpty_expression() throws RecognitionException { - IsNotEmpty_expressionContext _localctx = new IsNotEmpty_expressionContext(_ctx, getState()); - enterRule(_localctx, 66, RULE_isNotEmpty_expression); - try { - setState(298); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(290); - match(PATH_VARIABLE); - setState(291); - match(T__24); - setState(292); - match(T__21); - setState(293); - match(T__29); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(294); - match(PATH_VARIABLE); - setState(295); - match(T__31); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(296); - match(PATH_VARIABLE); - setState(297); - match(T__32); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Like_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Like_opContext like_op() { - return getRuleContext(Like_opContext.class,0); - } - public Value_expressionContext value_expression() { - return getRuleContext(Value_expressionContext.class,0); - } - public Like_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_like_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterLike_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitLike_expression(this); - } - } - - public final Like_expressionContext like_expression() throws RecognitionException { - Like_expressionContext _localctx = new Like_expressionContext(_ctx, getState()); - enterRule(_localctx, 68, RULE_like_expression); - try { - enterOuterAlt(_localctx, 1); - { - setState(300); - match(PATH_VARIABLE); - setState(301); - like_op(); - setState(302); - value_expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Like_opContext extends ParserRuleContext { - public Like_opContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_like_op; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterLike_op(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitLike_op(this); - } - } - - public final Like_opContext like_op() throws RecognitionException { - Like_opContext _localctx = new Like_opContext(_ctx, getState()); - enterRule(_localctx, 70, RULE_like_op); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(304); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40))) != 0)) ) { - _errHandler.recoverInline(this); - } else { - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Comparison_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Comparison_operatorContext comparison_operator() { - return getRuleContext(Comparison_operatorContext.class,0); - } - public Value_expressionContext value_expression() { - return getRuleContext(Value_expressionContext.class,0); - } - public Comparison_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_comparison_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterComparison_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitComparison_expression(this); - } - } - - public final Comparison_expressionContext comparison_expression() throws RecognitionException { - Comparison_expressionContext _localctx = new Comparison_expressionContext(_ctx, getState()); - enterRule(_localctx, 72, RULE_comparison_expression); - try { - setState(314); - switch (_input.LA(1)) { - case PATH_VARIABLE: - enterOuterAlt(_localctx, 1); - { - setState(306); - match(PATH_VARIABLE); - setState(307); - comparison_operator(); - setState(308); - value_expression(); - } - break; - case INPUT_VARIABLE: - case BOOLEAN_LITERAL: - case NUMBER_LITERAL: - case STRING_LITERAL: - enterOuterAlt(_localctx, 2); - { - setState(310); - value_expression(); - setState(311); - comparison_operator(); - setState(312); - match(PATH_VARIABLE); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Comparison_operatorContext extends ParserRuleContext { - public Comparison_operatorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_comparison_operator; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterComparison_operator(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitComparison_operator(this); - } - } - - public final Comparison_operatorContext comparison_operator() throws RecognitionException { - Comparison_operatorContext _localctx = new Comparison_operatorContext(_ctx, getState()); - enterRule(_localctx, 74, RULE_comparison_operator); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(316); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__41) | (1L << T__42) | (1L << T__43) | (1L << T__44) | (1L << T__45) | (1L << T__46) | (1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53) | (1L << T__54) | (1L << T__55) | (1L << T__56))) != 0)) ) { - _errHandler.recoverInline(this); - } else { - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Value_expressionContext extends ParserRuleContext { - public LiteralContext literal() { - return getRuleContext(LiteralContext.class,0); - } - public TerminalNode INPUT_VARIABLE() { return getToken(EQLParser.INPUT_VARIABLE, 0); } - public Value_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_value_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterValue_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitValue_expression(this); - } - } - - public final Value_expressionContext value_expression() throws RecognitionException { - Value_expressionContext _localctx = new Value_expressionContext(_ctx, getState()); - enterRule(_localctx, 76, RULE_value_expression); - try { - setState(320); - switch (_input.LA(1)) { - case BOOLEAN_LITERAL: - case NUMBER_LITERAL: - case STRING_LITERAL: - enterOuterAlt(_localctx, 1); - { - setState(318); - literal(); - } - break; - case INPUT_VARIABLE: - enterOuterAlt(_localctx, 2); - { - setState(319); - match(INPUT_VARIABLE); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class LiteralContext extends ParserRuleContext { - public TerminalNode STRING_LITERAL() { return getToken(EQLParser.STRING_LITERAL, 0); } - public TerminalNode BOOLEAN_LITERAL() { return getToken(EQLParser.BOOLEAN_LITERAL, 0); } - public TerminalNode NUMBER_LITERAL() { return getToken(EQLParser.NUMBER_LITERAL, 0); } - public LiteralContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_literal; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterLiteral(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitLiteral(this); - } - } - - public final LiteralContext literal() throws RecognitionException { - LiteralContext _localctx = new LiteralContext(_ctx, getState()); - enterRule(_localctx, 78, RULE_literal); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(322); - _la = _input.LA(1); - if ( !(((((_la - 60)) & ~0x3f) == 0 && ((1L << (_la - 60)) & ((1L << (BOOLEAN_LITERAL - 60)) | (1L << (NUMBER_LITERAL - 60)) | (1L << (STRING_LITERAL - 60)))) != 0)) ) { - _errHandler.recoverInline(this); - } else { - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3D\u0147\4\2\t\2\4"+ - "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ - "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ - "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ - "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\3\2\5\2T\n\2\3"+ - "\2\7\2W\n\2\f\2\16\2Z\13\2\3\2\5\2]\n\2\3\2\5\2`\n\2\3\2\5\2c\n\2\3\3"+ - "\3\3\5\3g\n\3\3\3\3\3\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\7\3\7\3\7"+ - "\3\7\3\7\7\7y\n\7\f\7\16\7|\13\7\3\b\3\b\5\b\u0080\n\b\3\b\5\b\u0083\n"+ - "\b\3\t\3\t\3\t\3\t\5\t\u0089\n\t\3\n\3\n\3\13\3\13\3\13\5\13\u0090\n\13"+ - "\3\f\3\f\3\f\3\r\3\r\5\r\u0097\n\r\3\r\3\r\5\r\u009b\n\r\3\16\3\16\3\16"+ - "\3\16\3\17\3\17\3\17\7\17\u00a4\n\17\f\17\16\17\u00a7\13\17\3\20\3\20"+ - "\3\20\5\20\u00ac\n\20\3\21\3\21\3\21\3\22\3\22\3\22\3\23\3\23\5\23\u00b6"+ - "\n\23\3\24\3\24\5\24\u00ba\n\24\3\25\3\25\5\25\u00be\n\25\3\26\3\26\3"+ - "\26\3\26\3\27\3\27\3\27\7\27\u00c7\n\27\f\27\16\27\u00ca\13\27\3\30\3"+ - "\30\3\30\7\30\u00cf\n\30\f\30\16\30\u00d2\13\30\3\31\5\31\u00d5\n\31\3"+ - "\31\3\31\3\32\3\32\3\32\3\32\3\32\5\32\u00de\n\32\3\33\3\33\3\33\3\33"+ - "\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\5\33\u00ed\n\33\3\34\3\34"+ - "\3\34\3\34\3\35\3\35\3\35\3\35\3\35\7\35\u00f8\n\35\f\35\16\35\u00fb\13"+ - "\35\3\35\3\35\5\35\u00ff\n\35\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37"+ - "\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3 \5 \u0112\n \3!\3!\3!\3!\3!\3!\3!\3"+ - "!\5!\u011c\n!\3\"\3\"\3\"\3\"\3\"\5\"\u0123\n\"\3#\3#\3#\3#\3#\3#\3#\3"+ - "#\5#\u012d\n#\3$\3$\3$\3$\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\5&\u013d\n&\3"+ - "\'\3\'\3(\3(\5(\u0143\n(\3)\3)\3)\2\2*\2\4\6\b\n\f\16\20\22\24\26\30\32"+ - "\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNP\2\6\3\2\16\17\3\2$+\3\2,;\4\2"+ - ">?CC\u0148\2S\3\2\2\2\4d\3\2\2\2\6l\3\2\2\2\bn\3\2\2\2\np\3\2\2\2\fs\3"+ - "\2\2\2\16}\3\2\2\2\20\u0088\3\2\2\2\22\u008a\3\2\2\2\24\u008c\3\2\2\2"+ - "\26\u0091\3\2\2\2\30\u0094\3\2\2\2\32\u009c\3\2\2\2\34\u00a0\3\2\2\2\36"+ - "\u00ab\3\2\2\2 \u00ad\3\2\2\2\"\u00b0\3\2\2\2$\u00b5\3\2\2\2&\u00b7\3"+ - "\2\2\2(\u00bb\3\2\2\2*\u00bf\3\2\2\2,\u00c3\3\2\2\2.\u00cb\3\2\2\2\60"+ - "\u00d4\3\2\2\2\62\u00dd\3\2\2\2\64\u00ec\3\2\2\2\66\u00ee\3\2\2\28\u00fe"+ - "\3\2\2\2:\u0100\3\2\2\2<\u0106\3\2\2\2>\u0111\3\2\2\2@\u011b\3\2\2\2B"+ - "\u0122\3\2\2\2D\u012c\3\2\2\2F\u012e\3\2\2\2H\u0132\3\2\2\2J\u013c\3\2"+ - "\2\2L\u013e\3\2\2\2N\u0142\3\2\2\2P\u0144\3\2\2\2RT\5\4\3\2SR\3\2\2\2"+ - "ST\3\2\2\2TX\3\2\2\2UW\5\b\5\2VU\3\2\2\2WZ\3\2\2\2XV\3\2\2\2XY\3\2\2\2"+ - "Y\\\3\2\2\2ZX\3\2\2\2[]\5\n\6\2\\[\3\2\2\2\\]\3\2\2\2]_\3\2\2\2^`\5\f"+ - "\7\2_^\3\2\2\2_`\3\2\2\2`b\3\2\2\2ac\5\24\13\2ba\3\2\2\2bc\3\2\2\2c\3"+ - "\3\2\2\2df\7\3\2\2eg\5\6\4\2fe\3\2\2\2fg\3\2\2\2gh\3\2\2\2hi\7\4\2\2i"+ - "j\5\34\17\2jk\7\5\2\2k\5\3\2\2\2lm\7\6\2\2m\7\3\2\2\2no\5\30\r\2o\t\3"+ - "\2\2\2pq\7\7\2\2qr\5,\27\2r\13\3\2\2\2st\7\b\2\2tu\7\t\2\2uz\5\16\b\2"+ - "vw\7\n\2\2wy\5\16\b\2xv\3\2\2\2y|\3\2\2\2zx\3\2\2\2z{\3\2\2\2{\r\3\2\2"+ - "\2|z\3\2\2\2}\177\7=\2\2~\u0080\5\22\n\2\177~\3\2\2\2\177\u0080\3\2\2"+ - "\2\u0080\u0082\3\2\2\2\u0081\u0083\5\20\t\2\u0082\u0081\3\2\2\2\u0082"+ - "\u0083\3\2\2\2\u0083\17\3\2\2\2\u0084\u0085\7\13\2\2\u0085\u0089\7\f\2"+ - "\2\u0086\u0087\7\13\2\2\u0087\u0089\7\r\2\2\u0088\u0084\3\2\2\2\u0088"+ - "\u0086\3\2\2\2\u0089\21\3\2\2\2\u008a\u008b\t\2\2\2\u008b\23\3\2\2\2\u008c"+ - "\u008d\7\20\2\2\u008d\u008f\7?\2\2\u008e\u0090\5\26\f\2\u008f\u008e\3"+ - "\2\2\2\u008f\u0090\3\2\2\2\u0090\25\3\2\2\2\u0091\u0092\7\21\2\2\u0092"+ - "\u0093\7?\2\2\u0093\27\3\2\2\2\u0094\u0096\7\22\2\2\u0095\u0097\5$\23"+ - "\2\u0096\u0095\3\2\2\2\u0096\u0097\3\2\2\2\u0097\u0098\3\2\2\2\u0098\u009a"+ - "\7=\2\2\u0099\u009b\5\32\16\2\u009a\u0099\3\2\2\2\u009a\u009b\3\2\2\2"+ - "\u009b\31\3\2\2\2\u009c\u009d\7\4\2\2\u009d\u009e\5\34\17\2\u009e\u009f"+ - "\7\5\2\2\u009f\33\3\2\2\2\u00a0\u00a5\5\36\20\2\u00a1\u00a2\7\n\2\2\u00a2"+ - "\u00a4\5\36\20\2\u00a3\u00a1\3\2\2\2\u00a4\u00a7\3\2\2\2\u00a5\u00a3\3"+ - "\2\2\2\u00a5\u00a6\3\2\2\2\u00a6\35\3\2\2\2\u00a7\u00a5\3\2\2\2\u00a8"+ - "\u00ac\7=\2\2\u00a9\u00ac\5 \21\2\u00aa\u00ac\5\"\22\2\u00ab\u00a8\3\2"+ - "\2\2\u00ab\u00a9\3\2\2\2\u00ab\u00aa\3\2\2\2\u00ac\37\3\2\2\2\u00ad\u00ae"+ - "\7\23\2\2\u00ae\u00af\5&\24\2\u00af!\3\2\2\2\u00b0\u00b1\7\23\2\2\u00b1"+ - "\u00b2\5(\25\2\u00b2#\3\2\2\2\u00b3\u00b6\5&\24\2\u00b4\u00b6\5(\25\2"+ - "\u00b5\u00b3\3\2\2\2\u00b5\u00b4\3\2\2\2\u00b6%\3\2\2\2\u00b7\u00b9\7"+ - "\24\2\2\u00b8\u00ba\5*\26\2\u00b9\u00b8\3\2\2\2\u00b9\u00ba\3\2\2\2\u00ba"+ - "\'\3\2\2\2\u00bb\u00bd\7\25\2\2\u00bc\u00be\5*\26\2\u00bd\u00bc\3\2\2"+ - "\2\u00bd\u00be\3\2\2\2\u00be)\3\2\2\2\u00bf\u00c0\7\4\2\2\u00c0\u00c1"+ - "\7?\2\2\u00c1\u00c2\7\5\2\2\u00c2+\3\2\2\2\u00c3\u00c8\5.\30\2\u00c4\u00c5"+ - "\7\26\2\2\u00c5\u00c7\5.\30\2\u00c6\u00c4\3\2\2\2\u00c7\u00ca\3\2\2\2"+ - "\u00c8\u00c6\3\2\2\2\u00c8\u00c9\3\2\2\2\u00c9-\3\2\2\2\u00ca\u00c8\3"+ - "\2\2\2\u00cb\u00d0\5\60\31\2\u00cc\u00cd\7\27\2\2\u00cd\u00cf\5\60\31"+ - "\2\u00ce\u00cc\3\2\2\2\u00cf\u00d2\3\2\2\2\u00d0\u00ce\3\2\2\2\u00d0\u00d1"+ - "\3\2\2\2\u00d1/\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d3\u00d5\7\30\2\2\u00d4"+ - "\u00d3\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d6\3\2\2\2\u00d6\u00d7\5\62"+ - "\32\2\u00d7\61\3\2\2\2\u00d8\u00de\5\64\33\2\u00d9\u00da\7\4\2\2\u00da"+ - "\u00db\5,\27\2\u00db\u00dc\7\5\2\2\u00dc\u00de\3\2\2\2\u00dd\u00d8\3\2"+ - "\2\2\u00dd\u00d9\3\2\2\2\u00de\63\3\2\2\2\u00df\u00ed\5J&\2\u00e0\u00ed"+ - "\5F$\2\u00e1\u00ed\5:\36\2\u00e2\u00ed\5<\37\2\u00e3\u00ed\5\66\34\2\u00e4"+ - "\u00ed\5> \2\u00e5\u00ed\5@!\2\u00e6\u00ed\5B\"\2\u00e7\u00ed\5D#\2\u00e8"+ - "\u00e9\7\4\2\2\u00e9\u00ea\5\64\33\2\u00ea\u00eb\7\5\2\2\u00eb\u00ed\3"+ - "\2\2\2\u00ec\u00df\3\2\2\2\u00ec\u00e0\3\2\2\2\u00ec\u00e1\3\2\2\2\u00ec"+ - "\u00e2\3\2\2\2\u00ec\u00e3\3\2\2\2\u00ec\u00e4\3\2\2\2\u00ec\u00e5\3\2"+ - "\2\2\u00ec\u00e6\3\2\2\2\u00ec\u00e7\3\2\2\2\u00ec\u00e8\3\2\2\2\u00ed"+ - "\65\3\2\2\2\u00ee\u00ef\7=\2\2\u00ef\u00f0\7\31\2\2\u00f0\u00f1\58\35"+ - "\2\u00f1\67\3\2\2\2\u00f2\u00ff\7<\2\2\u00f3\u00f4\7\4\2\2\u00f4\u00f9"+ - "\5N(\2\u00f5\u00f6\7\n\2\2\u00f6\u00f8\5N(\2\u00f7\u00f5\3\2\2\2\u00f8"+ - "\u00fb\3\2\2\2\u00f9\u00f7\3\2\2\2\u00f9\u00fa\3\2\2\2\u00fa\u00fc\3\2"+ - "\2\2\u00fb\u00f9\3\2\2\2\u00fc\u00fd\7\5\2\2\u00fd\u00ff\3\2\2\2\u00fe"+ - "\u00f2\3\2\2\2\u00fe\u00f3\3\2\2\2\u00ff9\3\2\2\2\u0100\u0101\7=\2\2\u0101"+ - "\u0102\7\32\2\2\u0102\u0103\5N(\2\u0103\u0104\7\27\2\2\u0104\u0105\5N"+ - "(\2\u0105;\3\2\2\2\u0106\u0107\5N(\2\u0107\u0108\7\32\2\2\u0108\u0109"+ - "\7=\2\2\u0109\u010a\7\27\2\2\u010a\u010b\7=\2\2\u010b=\3\2\2\2\u010c\u010d"+ - "\7=\2\2\u010d\u010e\7\33\2\2\u010e\u0112\7\34\2\2\u010f\u0110\7=\2\2\u0110"+ - "\u0112\7\35\2\2\u0111\u010c\3\2\2\2\u0111\u010f\3\2\2\2\u0112?\3\2\2\2"+ - "\u0113\u0114\7=\2\2\u0114\u0115\7\33\2\2\u0115\u0116\7\30\2\2\u0116\u011c"+ - "\7\34\2\2\u0117\u0118\7=\2\2\u0118\u011c\7\36\2\2\u0119\u011a\7=\2\2\u011a"+ - "\u011c\7\37\2\2\u011b\u0113\3\2\2\2\u011b\u0117\3\2\2\2\u011b\u0119\3"+ - "\2\2\2\u011cA\3\2\2\2\u011d\u011e\7=\2\2\u011e\u011f\7\33\2\2\u011f\u0123"+ - "\7 \2\2\u0120\u0121\7=\2\2\u0121\u0123\7!\2\2\u0122\u011d\3\2\2\2\u0122"+ - "\u0120\3\2\2\2\u0123C\3\2\2\2\u0124\u0125\7=\2\2\u0125\u0126\7\33\2\2"+ - "\u0126\u0127\7\30\2\2\u0127\u012d\7 \2\2\u0128\u0129\7=\2\2\u0129\u012d"+ - "\7\"\2\2\u012a\u012b\7=\2\2\u012b\u012d\7#\2\2\u012c\u0124\3\2\2\2\u012c"+ - "\u0128\3\2\2\2\u012c\u012a\3\2\2\2\u012dE\3\2\2\2\u012e\u012f\7=\2\2\u012f"+ - "\u0130\5H%\2\u0130\u0131\5N(\2\u0131G\3\2\2\2\u0132\u0133\t\3\2\2\u0133"+ - "I\3\2\2\2\u0134\u0135\7=\2\2\u0135\u0136\5L\'\2\u0136\u0137\5N(\2\u0137"+ - "\u013d\3\2\2\2\u0138\u0139\5N(\2\u0139\u013a\5L\'\2\u013a\u013b\7=\2\2"+ - "\u013b\u013d\3\2\2\2\u013c\u0134\3\2\2\2\u013c\u0138\3\2\2\2\u013dK\3"+ - "\2\2\2\u013e\u013f\t\4\2\2\u013fM\3\2\2\2\u0140\u0143\5P)\2\u0141\u0143"+ - "\7<\2\2\u0142\u0140\3\2\2\2\u0142\u0141\3\2\2\2\u0143O\3\2\2\2\u0144\u0145"+ - "\t\5\2\2\u0145Q\3\2\2\2!SX\\_bfz\177\u0082\u0088\u008f\u0096\u009a\u00a5"+ - "\u00ab\u00b5\u00b9\u00bd\u00c8\u00d0\u00d4\u00dd\u00ec\u00f9\u00fe\u0111"+ - "\u011b\u0122\u012c\u013c\u0142"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file + public EQLParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); + } + + public static class Select_statementContext extends ParserRuleContext { + public Select_clauseContext select_clause() { + return getRuleContext(Select_clauseContext.class, 0); + } + + public List fetch_clause() { + return getRuleContexts(Fetch_clauseContext.class); + } + + public Fetch_clauseContext fetch_clause(int i) { + return getRuleContext(Fetch_clauseContext.class, i); + } + + public Where_clauseContext where_clause() { + return getRuleContext(Where_clauseContext.class, 0); + } + + public Orderby_clauseContext orderby_clause() { + return getRuleContext(Orderby_clauseContext.class, 0); + } + + public Limit_clauseContext limit_clause() { + return getRuleContext(Limit_clauseContext.class, 0); + } + + public Select_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_select_statement; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterSelect_statement(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitSelect_statement(this); + } + } + + public final Select_statementContext select_statement() throws RecognitionException { + Select_statementContext _localctx = new Select_statementContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_select_statement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(81); + _la = _input.LA(1); + if (_la == T__0) { + { + setState(80); + select_clause(); + } + } + + setState(86); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__15) { + { + { + setState(83); + fetch_clause(); + } + } + setState(88); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(90); + _la = _input.LA(1); + if (_la == T__4) { + { + setState(89); + where_clause(); + } + } + + setState(93); + _la = _input.LA(1); + if (_la == T__5) { + { + setState(92); + orderby_clause(); + } + } + + setState(96); + _la = _input.LA(1); + if (_la == T__13) { + { + setState(95); + limit_clause(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Select_clauseContext extends ParserRuleContext { + public Fetch_property_groupContext fetch_property_group() { + return getRuleContext(Fetch_property_groupContext.class, 0); + } + + public DistinctContext distinct() { + return getRuleContext(DistinctContext.class, 0); + } + + public Select_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_select_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterSelect_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitSelect_clause(this); + } + } + + public final Select_clauseContext select_clause() throws RecognitionException { + Select_clauseContext _localctx = new Select_clauseContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_select_clause); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(98); + match(T__0); + setState(100); + _la = _input.LA(1); + if (_la == T__3) { + { + setState(99); + distinct(); + } + } + + setState(102); + match(T__1); + setState(103); + fetch_property_group(); + setState(104); + match(T__2); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class DistinctContext extends ParserRuleContext { + public DistinctContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_distinct; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterDistinct(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitDistinct(this); + } + } + + public final DistinctContext distinct() throws RecognitionException { + DistinctContext _localctx = new DistinctContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_distinct); + try { + enterOuterAlt(_localctx, 1); + { + setState(106); + match(T__3); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_clauseContext extends ParserRuleContext { + public Fetch_pathContext fetch_path() { + return getRuleContext(Fetch_pathContext.class, 0); + } + + public Fetch_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_clause(this); + } + } + + public final Fetch_clauseContext fetch_clause() throws RecognitionException { + Fetch_clauseContext _localctx = new Fetch_clauseContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_fetch_clause); + try { + enterOuterAlt(_localctx, 1); + { + setState(108); + fetch_path(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Where_clauseContext extends ParserRuleContext { + public Conditional_expressionContext conditional_expression() { + return getRuleContext(Conditional_expressionContext.class, 0); + } + + public Where_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_where_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterWhere_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitWhere_clause(this); + } + } + + public final Where_clauseContext where_clause() throws RecognitionException { + Where_clauseContext _localctx = new Where_clauseContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_where_clause); + try { + enterOuterAlt(_localctx, 1); + { + setState(110); + match(T__4); + setState(111); + conditional_expression(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Orderby_clauseContext extends ParserRuleContext { + public List orderby_property() { + return getRuleContexts(Orderby_propertyContext.class); + } + + public Orderby_propertyContext orderby_property(int i) { + return getRuleContext(Orderby_propertyContext.class, i); + } + + public Orderby_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_orderby_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterOrderby_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitOrderby_clause(this); + } + } + + public final Orderby_clauseContext orderby_clause() throws RecognitionException { + Orderby_clauseContext _localctx = new Orderby_clauseContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_orderby_clause); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(113); + match(T__5); + setState(114); + match(T__6); + setState(115); + orderby_property(); + setState(120); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__7) { + { + { + setState(116); + match(T__7); + setState(117); + orderby_property(); + } + } + setState(122); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Orderby_propertyContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Asc_descContext asc_desc() { + return getRuleContext(Asc_descContext.class, 0); + } + + public Nulls_firstlastContext nulls_firstlast() { + return getRuleContext(Nulls_firstlastContext.class, 0); + } + + public Orderby_propertyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_orderby_property; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterOrderby_property(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitOrderby_property(this); + } + } + + public final Orderby_propertyContext orderby_property() throws RecognitionException { + Orderby_propertyContext _localctx = new Orderby_propertyContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_orderby_property); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(123); + match(PATH_VARIABLE); + setState(125); + _la = _input.LA(1); + if (_la == T__11 || _la == T__12) { + { + setState(124); + asc_desc(); + } + } + + setState(128); + _la = _input.LA(1); + if (_la == T__8) { + { + setState(127); + nulls_firstlast(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Nulls_firstlastContext extends ParserRuleContext { + public Nulls_firstlastContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_nulls_firstlast; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterNulls_firstlast(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitNulls_firstlast(this); + } + } + + public final Nulls_firstlastContext nulls_firstlast() throws RecognitionException { + Nulls_firstlastContext _localctx = new Nulls_firstlastContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_nulls_firstlast); + try { + setState(134); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 9, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(130); + match(T__8); + setState(131); + match(T__9); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(132); + match(T__8); + setState(133); + match(T__10); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Asc_descContext extends ParserRuleContext { + public Asc_descContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_asc_desc; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterAsc_desc(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitAsc_desc(this); + } + } + + public final Asc_descContext asc_desc() throws RecognitionException { + Asc_descContext _localctx = new Asc_descContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_asc_desc); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(136); + _la = _input.LA(1); + if (!(_la == T__11 || _la == T__12)) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Limit_clauseContext extends ParserRuleContext { + public TerminalNode NUMBER_LITERAL() { + return getToken(EQLParser.NUMBER_LITERAL, 0); + } + + public Offset_clauseContext offset_clause() { + return getRuleContext(Offset_clauseContext.class, 0); + } + + public Limit_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_limit_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterLimit_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitLimit_clause(this); + } + } + + public final Limit_clauseContext limit_clause() throws RecognitionException { + Limit_clauseContext _localctx = new Limit_clauseContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_limit_clause); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(138); + match(T__13); + setState(139); + match(NUMBER_LITERAL); + setState(141); + _la = _input.LA(1); + if (_la == T__14) { + { + setState(140); + offset_clause(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Offset_clauseContext extends ParserRuleContext { + public TerminalNode NUMBER_LITERAL() { + return getToken(EQLParser.NUMBER_LITERAL, 0); + } + + public Offset_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_offset_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterOffset_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitOffset_clause(this); + } + } + + public final Offset_clauseContext offset_clause() throws RecognitionException { + Offset_clauseContext _localctx = new Offset_clauseContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_offset_clause); + try { + enterOuterAlt(_localctx, 1); + { + setState(143); + match(T__14); + setState(144); + match(NUMBER_LITERAL); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_pathContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Fetch_optionContext fetch_option() { + return getRuleContext(Fetch_optionContext.class, 0); + } + + public Fetch_property_setContext fetch_property_set() { + return getRuleContext(Fetch_property_setContext.class, 0); + } + + public Fetch_pathContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_path; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_path(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_path(this); + } + } + + public final Fetch_pathContext fetch_path() throws RecognitionException { + Fetch_pathContext _localctx = new Fetch_pathContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_fetch_path); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(146); + match(T__15); + setState(148); + _la = _input.LA(1); + if (_la == T__17 || _la == T__18) { + { + setState(147); + fetch_option(); + } + } + + setState(150); + match(PATH_VARIABLE); + setState(152); + _la = _input.LA(1); + if (_la == T__1) { + { + setState(151); + fetch_property_set(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_property_setContext extends ParserRuleContext { + public Fetch_property_groupContext fetch_property_group() { + return getRuleContext(Fetch_property_groupContext.class, 0); + } + + public Fetch_property_setContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_property_set; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_property_set(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_property_set(this); + } + } + + public final Fetch_property_setContext fetch_property_set() throws RecognitionException { + Fetch_property_setContext _localctx = new Fetch_property_setContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_fetch_property_set); + try { + enterOuterAlt(_localctx, 1); + { + setState(154); + match(T__1); + setState(155); + fetch_property_group(); + setState(156); + match(T__2); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_property_groupContext extends ParserRuleContext { + public List fetch_property() { + return getRuleContexts(Fetch_propertyContext.class); + } + + public Fetch_propertyContext fetch_property(int i) { + return getRuleContext(Fetch_propertyContext.class, i); + } + + public Fetch_property_groupContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_property_group; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_property_group(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_property_group(this); + } + } + + public final Fetch_property_groupContext fetch_property_group() throws RecognitionException { + Fetch_property_groupContext _localctx = new Fetch_property_groupContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_fetch_property_group); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(158); + fetch_property(); + setState(163); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__7) { + { + { + setState(159); + match(T__7); + setState(160); + fetch_property(); + } + } + setState(165); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_propertyContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Fetch_query_hintContext fetch_query_hint() { + return getRuleContext(Fetch_query_hintContext.class, 0); + } + + public Fetch_lazy_hintContext fetch_lazy_hint() { + return getRuleContext(Fetch_lazy_hintContext.class, 0); + } + + public Fetch_propertyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_property; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_property(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_property(this); + } + } + + public final Fetch_propertyContext fetch_property() throws RecognitionException { + Fetch_propertyContext _localctx = new Fetch_propertyContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_fetch_property); + try { + setState(169); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 14, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(166); + match(PATH_VARIABLE); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(167); + fetch_query_hint(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(168); + fetch_lazy_hint(); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_query_hintContext extends ParserRuleContext { + public Fetch_query_optionContext fetch_query_option() { + return getRuleContext(Fetch_query_optionContext.class, 0); + } + + public Fetch_query_hintContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_query_hint; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_query_hint(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_query_hint(this); + } + } + + public final Fetch_query_hintContext fetch_query_hint() throws RecognitionException { + Fetch_query_hintContext _localctx = new Fetch_query_hintContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_fetch_query_hint); + try { + enterOuterAlt(_localctx, 1); + { + setState(171); + match(T__16); + setState(172); + fetch_query_option(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_lazy_hintContext extends ParserRuleContext { + public Fetch_lazy_optionContext fetch_lazy_option() { + return getRuleContext(Fetch_lazy_optionContext.class, 0); + } + + public Fetch_lazy_hintContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_lazy_hint; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_lazy_hint(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_lazy_hint(this); + } + } + + public final Fetch_lazy_hintContext fetch_lazy_hint() throws RecognitionException { + Fetch_lazy_hintContext _localctx = new Fetch_lazy_hintContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_fetch_lazy_hint); + try { + enterOuterAlt(_localctx, 1); + { + setState(174); + match(T__16); + setState(175); + fetch_lazy_option(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_optionContext extends ParserRuleContext { + public Fetch_query_optionContext fetch_query_option() { + return getRuleContext(Fetch_query_optionContext.class, 0); + } + + public Fetch_lazy_optionContext fetch_lazy_option() { + return getRuleContext(Fetch_lazy_optionContext.class, 0); + } + + public Fetch_optionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_option; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_option(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_option(this); + } + } + + public final Fetch_optionContext fetch_option() throws RecognitionException { + Fetch_optionContext _localctx = new Fetch_optionContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_fetch_option); + try { + setState(179); + switch (_input.LA(1)) { + case T__17: + enterOuterAlt(_localctx, 1); + { + setState(177); + fetch_query_option(); + } + break; + case T__18: + enterOuterAlt(_localctx, 2); + { + setState(178); + fetch_lazy_option(); + } + break; + default: + throw new NoViableAltException(this); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_query_optionContext extends ParserRuleContext { + public Fetch_batch_sizeContext fetch_batch_size() { + return getRuleContext(Fetch_batch_sizeContext.class, 0); + } + + public Fetch_query_optionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_query_option; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_query_option(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_query_option(this); + } + } + + public final Fetch_query_optionContext fetch_query_option() throws RecognitionException { + Fetch_query_optionContext _localctx = new Fetch_query_optionContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_fetch_query_option); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(181); + match(T__17); + setState(183); + _la = _input.LA(1); + if (_la == T__1) { + { + setState(182); + fetch_batch_size(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_lazy_optionContext extends ParserRuleContext { + public Fetch_batch_sizeContext fetch_batch_size() { + return getRuleContext(Fetch_batch_sizeContext.class, 0); + } + + public Fetch_lazy_optionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_lazy_option; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_lazy_option(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_lazy_option(this); + } + } + + public final Fetch_lazy_optionContext fetch_lazy_option() throws RecognitionException { + Fetch_lazy_optionContext _localctx = new Fetch_lazy_optionContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_fetch_lazy_option); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(185); + match(T__18); + setState(187); + _la = _input.LA(1); + if (_la == T__1) { + { + setState(186); + fetch_batch_size(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_batch_sizeContext extends ParserRuleContext { + public TerminalNode NUMBER_LITERAL() { + return getToken(EQLParser.NUMBER_LITERAL, 0); + } + + public Fetch_batch_sizeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_batch_size; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_batch_size(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_batch_size(this); + } + } + + public final Fetch_batch_sizeContext fetch_batch_size() throws RecognitionException { + Fetch_batch_sizeContext _localctx = new Fetch_batch_sizeContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_fetch_batch_size); + try { + enterOuterAlt(_localctx, 1); + { + setState(189); + match(T__1); + setState(190); + match(NUMBER_LITERAL); + setState(191); + match(T__2); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Conditional_expressionContext extends ParserRuleContext { + public List conditional_term() { + return getRuleContexts(Conditional_termContext.class); + } + + public Conditional_termContext conditional_term(int i) { + return getRuleContext(Conditional_termContext.class, i); + } + + public Conditional_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_conditional_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterConditional_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitConditional_expression(this); + } + } + + public final Conditional_expressionContext conditional_expression() throws RecognitionException { + Conditional_expressionContext _localctx = new Conditional_expressionContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_conditional_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(193); + conditional_term(); + setState(198); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__19) { + { + { + setState(194); + match(T__19); + setState(195); + conditional_term(); + } + } + setState(200); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Conditional_termContext extends ParserRuleContext { + public List conditional_factor() { + return getRuleContexts(Conditional_factorContext.class); + } + + public Conditional_factorContext conditional_factor(int i) { + return getRuleContext(Conditional_factorContext.class, i); + } + + public Conditional_termContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_conditional_term; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterConditional_term(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitConditional_term(this); + } + } + + public final Conditional_termContext conditional_term() throws RecognitionException { + Conditional_termContext _localctx = new Conditional_termContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_conditional_term); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(201); + conditional_factor(); + setState(206); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__20) { + { + { + setState(202); + match(T__20); + setState(203); + conditional_factor(); + } + } + setState(208); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Conditional_factorContext extends ParserRuleContext { + public Conditional_primaryContext conditional_primary() { + return getRuleContext(Conditional_primaryContext.class, 0); + } + + public Conditional_factorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_conditional_factor; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterConditional_factor(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitConditional_factor(this); + } + } + + public final Conditional_factorContext conditional_factor() throws RecognitionException { + Conditional_factorContext _localctx = new Conditional_factorContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_conditional_factor); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(210); + _la = _input.LA(1); + if (_la == T__21) { + { + setState(209); + match(T__21); + } + } + + setState(212); + conditional_primary(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Conditional_primaryContext extends ParserRuleContext { + public Any_expressionContext any_expression() { + return getRuleContext(Any_expressionContext.class, 0); + } + + public Conditional_expressionContext conditional_expression() { + return getRuleContext(Conditional_expressionContext.class, 0); + } + + public Conditional_primaryContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_conditional_primary; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterConditional_primary(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitConditional_primary(this); + } + } + + public final Conditional_primaryContext conditional_primary() throws RecognitionException { + Conditional_primaryContext _localctx = new Conditional_primaryContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_conditional_primary); + try { + setState(219); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 21, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(214); + any_expression(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(215); + match(T__1); + setState(216); + conditional_expression(); + setState(217); + match(T__2); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Any_expressionContext extends ParserRuleContext { + public Comparison_expressionContext comparison_expression() { + return getRuleContext(Comparison_expressionContext.class, 0); + } + + public Like_expressionContext like_expression() { + return getRuleContext(Like_expressionContext.class, 0); + } + + public Between_expressionContext between_expression() { + return getRuleContext(Between_expressionContext.class, 0); + } + + public PropertyBetween_expressionContext propertyBetween_expression() { + return getRuleContext(PropertyBetween_expressionContext.class, 0); + } + + public In_expressionContext in_expression() { + return getRuleContext(In_expressionContext.class, 0); + } + + public IsNull_expressionContext isNull_expression() { + return getRuleContext(IsNull_expressionContext.class, 0); + } + + public IsNotNull_expressionContext isNotNull_expression() { + return getRuleContext(IsNotNull_expressionContext.class, 0); + } + + public IsEmpty_expressionContext isEmpty_expression() { + return getRuleContext(IsEmpty_expressionContext.class, 0); + } + + public IsNotEmpty_expressionContext isNotEmpty_expression() { + return getRuleContext(IsNotEmpty_expressionContext.class, 0); + } + + public Any_expressionContext any_expression() { + return getRuleContext(Any_expressionContext.class, 0); + } + + public Any_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_any_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterAny_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitAny_expression(this); + } + } + + public final Any_expressionContext any_expression() throws RecognitionException { + Any_expressionContext _localctx = new Any_expressionContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_any_expression); + try { + setState(234); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 22, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(221); + comparison_expression(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(222); + like_expression(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(223); + between_expression(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(224); + propertyBetween_expression(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(225); + in_expression(); + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(226); + isNull_expression(); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(227); + isNotNull_expression(); + } + break; + case 8: + enterOuterAlt(_localctx, 8); + { + setState(228); + isEmpty_expression(); + } + break; + case 9: + enterOuterAlt(_localctx, 9); + { + setState(229); + isNotEmpty_expression(); + } + break; + case 10: + enterOuterAlt(_localctx, 10); + { + setState(230); + match(T__1); + setState(231); + any_expression(); + setState(232); + match(T__2); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class In_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public In_valueContext in_value() { + return getRuleContext(In_valueContext.class, 0); + } + + public In_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_in_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIn_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIn_expression(this); + } + } + + public final In_expressionContext in_expression() throws RecognitionException { + In_expressionContext _localctx = new In_expressionContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_in_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(236); + match(PATH_VARIABLE); + setState(237); + match(T__22); + setState(238); + in_value(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class In_valueContext extends ParserRuleContext { + public TerminalNode INPUT_VARIABLE() { + return getToken(EQLParser.INPUT_VARIABLE, 0); + } + + public List value_expression() { + return getRuleContexts(Value_expressionContext.class); + } + + public Value_expressionContext value_expression(int i) { + return getRuleContext(Value_expressionContext.class, i); + } + + public In_valueContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_in_value; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIn_value(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIn_value(this); + } + } + + public final In_valueContext in_value() throws RecognitionException { + In_valueContext _localctx = new In_valueContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_in_value); + int _la; + try { + setState(252); + switch (_input.LA(1)) { + case INPUT_VARIABLE: + enterOuterAlt(_localctx, 1); + { + setState(240); + match(INPUT_VARIABLE); + } + break; + case T__1: + enterOuterAlt(_localctx, 2); + { + setState(241); + match(T__1); + setState(242); + value_expression(); + setState(247); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__7) { + { + { + setState(243); + match(T__7); + setState(244); + value_expression(); + } + } + setState(249); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(250); + match(T__2); + } + break; + default: + throw new NoViableAltException(this); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Between_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public List value_expression() { + return getRuleContexts(Value_expressionContext.class); + } + + public Value_expressionContext value_expression(int i) { + return getRuleContext(Value_expressionContext.class, i); + } + + public Between_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_between_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterBetween_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitBetween_expression(this); + } + } + + public final Between_expressionContext between_expression() throws RecognitionException { + Between_expressionContext _localctx = new Between_expressionContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_between_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(254); + match(PATH_VARIABLE); + setState(255); + match(T__23); + setState(256); + value_expression(); + setState(257); + match(T__20); + setState(258); + value_expression(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class PropertyBetween_expressionContext extends ParserRuleContext { + public Value_expressionContext value_expression() { + return getRuleContext(Value_expressionContext.class, 0); + } + + public List PATH_VARIABLE() { + return getTokens(EQLParser.PATH_VARIABLE); + } + + public TerminalNode PATH_VARIABLE(int i) { + return getToken(EQLParser.PATH_VARIABLE, i); + } + + public PropertyBetween_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_propertyBetween_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterPropertyBetween_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitPropertyBetween_expression(this); + } + } + + public final PropertyBetween_expressionContext propertyBetween_expression() throws RecognitionException { + PropertyBetween_expressionContext _localctx = new PropertyBetween_expressionContext(_ctx, getState()); + enterRule(_localctx, 58, RULE_propertyBetween_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(260); + value_expression(); + setState(261); + match(T__23); + setState(262); + match(PATH_VARIABLE); + setState(263); + match(T__20); + setState(264); + match(PATH_VARIABLE); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class IsNull_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public IsNull_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_isNull_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIsNull_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIsNull_expression(this); + } + } + + public final IsNull_expressionContext isNull_expression() throws RecognitionException { + IsNull_expressionContext _localctx = new IsNull_expressionContext(_ctx, getState()); + enterRule(_localctx, 60, RULE_isNull_expression); + try { + setState(271); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 25, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(266); + match(PATH_VARIABLE); + setState(267); + match(T__24); + setState(268); + match(T__25); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(269); + match(PATH_VARIABLE); + setState(270); + match(T__26); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class IsNotNull_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public IsNotNull_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_isNotNull_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIsNotNull_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIsNotNull_expression(this); + } + } + + public final IsNotNull_expressionContext isNotNull_expression() throws RecognitionException { + IsNotNull_expressionContext _localctx = new IsNotNull_expressionContext(_ctx, getState()); + enterRule(_localctx, 62, RULE_isNotNull_expression); + try { + setState(281); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 26, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(273); + match(PATH_VARIABLE); + setState(274); + match(T__24); + setState(275); + match(T__21); + setState(276); + match(T__25); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(277); + match(PATH_VARIABLE); + setState(278); + match(T__27); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(279); + match(PATH_VARIABLE); + setState(280); + match(T__28); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class IsEmpty_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public IsEmpty_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_isEmpty_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIsEmpty_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIsEmpty_expression(this); + } + } + + public final IsEmpty_expressionContext isEmpty_expression() throws RecognitionException { + IsEmpty_expressionContext _localctx = new IsEmpty_expressionContext(_ctx, getState()); + enterRule(_localctx, 64, RULE_isEmpty_expression); + try { + setState(288); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 27, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(283); + match(PATH_VARIABLE); + setState(284); + match(T__24); + setState(285); + match(T__29); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(286); + match(PATH_VARIABLE); + setState(287); + match(T__30); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class IsNotEmpty_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public IsNotEmpty_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_isNotEmpty_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIsNotEmpty_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIsNotEmpty_expression(this); + } + } + + public final IsNotEmpty_expressionContext isNotEmpty_expression() throws RecognitionException { + IsNotEmpty_expressionContext _localctx = new IsNotEmpty_expressionContext(_ctx, getState()); + enterRule(_localctx, 66, RULE_isNotEmpty_expression); + try { + setState(298); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 28, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(290); + match(PATH_VARIABLE); + setState(291); + match(T__24); + setState(292); + match(T__21); + setState(293); + match(T__29); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(294); + match(PATH_VARIABLE); + setState(295); + match(T__31); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(296); + match(PATH_VARIABLE); + setState(297); + match(T__32); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Like_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Like_opContext like_op() { + return getRuleContext(Like_opContext.class, 0); + } + + public Value_expressionContext value_expression() { + return getRuleContext(Value_expressionContext.class, 0); + } + + public Like_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_like_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterLike_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitLike_expression(this); + } + } + + public final Like_expressionContext like_expression() throws RecognitionException { + Like_expressionContext _localctx = new Like_expressionContext(_ctx, getState()); + enterRule(_localctx, 68, RULE_like_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(300); + match(PATH_VARIABLE); + setState(301); + like_op(); + setState(302); + value_expression(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Like_opContext extends ParserRuleContext { + public Like_opContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_like_op; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterLike_op(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitLike_op(this); + } + } + + public final Like_opContext like_op() throws RecognitionException { + Like_opContext _localctx = new Like_opContext(_ctx, getState()); + enterRule(_localctx, 70, RULE_like_op); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(304); + _la = _input.LA(1); + if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40))) != 0))) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Comparison_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Comparison_operatorContext comparison_operator() { + return getRuleContext(Comparison_operatorContext.class, 0); + } + + public Value_expressionContext value_expression() { + return getRuleContext(Value_expressionContext.class, 0); + } + + public Comparison_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_comparison_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterComparison_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitComparison_expression(this); + } + } + + public final Comparison_expressionContext comparison_expression() throws RecognitionException { + Comparison_expressionContext _localctx = new Comparison_expressionContext(_ctx, getState()); + enterRule(_localctx, 72, RULE_comparison_expression); + try { + setState(314); + switch (_input.LA(1)) { + case PATH_VARIABLE: + enterOuterAlt(_localctx, 1); + { + setState(306); + match(PATH_VARIABLE); + setState(307); + comparison_operator(); + setState(308); + value_expression(); + } + break; + case INPUT_VARIABLE: + case BOOLEAN_LITERAL: + case NUMBER_LITERAL: + case STRING_LITERAL: + enterOuterAlt(_localctx, 2); + { + setState(310); + value_expression(); + setState(311); + comparison_operator(); + setState(312); + match(PATH_VARIABLE); + } + break; + default: + throw new NoViableAltException(this); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Comparison_operatorContext extends ParserRuleContext { + public Comparison_operatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_comparison_operator; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterComparison_operator(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitComparison_operator(this); + } + } + + public final Comparison_operatorContext comparison_operator() throws RecognitionException { + Comparison_operatorContext _localctx = new Comparison_operatorContext(_ctx, getState()); + enterRule(_localctx, 74, RULE_comparison_operator); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(316); + _la = _input.LA(1); + if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__41) | (1L << T__42) | (1L << T__43) | (1L << T__44) | (1L << T__45) | (1L << T__46) | (1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53) | (1L << T__54) | (1L << T__55) | (1L << T__56))) != 0))) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Value_expressionContext extends ParserRuleContext { + public LiteralContext literal() { + return getRuleContext(LiteralContext.class, 0); + } + + public TerminalNode INPUT_VARIABLE() { + return getToken(EQLParser.INPUT_VARIABLE, 0); + } + + public Value_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_value_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterValue_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitValue_expression(this); + } + } + + public final Value_expressionContext value_expression() throws RecognitionException { + Value_expressionContext _localctx = new Value_expressionContext(_ctx, getState()); + enterRule(_localctx, 76, RULE_value_expression); + try { + setState(320); + switch (_input.LA(1)) { + case BOOLEAN_LITERAL: + case NUMBER_LITERAL: + case STRING_LITERAL: + enterOuterAlt(_localctx, 1); + { + setState(318); + literal(); + } + break; + case INPUT_VARIABLE: + enterOuterAlt(_localctx, 2); + { + setState(319); + match(INPUT_VARIABLE); + } + break; + default: + throw new NoViableAltException(this); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class LiteralContext extends ParserRuleContext { + public TerminalNode STRING_LITERAL() { + return getToken(EQLParser.STRING_LITERAL, 0); + } + + public TerminalNode BOOLEAN_LITERAL() { + return getToken(EQLParser.BOOLEAN_LITERAL, 0); + } + + public TerminalNode NUMBER_LITERAL() { + return getToken(EQLParser.NUMBER_LITERAL, 0); + } + + public LiteralContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_literal; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterLiteral(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitLiteral(this); + } + } + + public final LiteralContext literal() throws RecognitionException { + LiteralContext _localctx = new LiteralContext(_ctx, getState()); + enterRule(_localctx, 78, RULE_literal); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(322); + _la = _input.LA(1); + if (!(((((_la - 60)) & ~0x3f) == 0 && ((1L << (_la - 60)) & ((1L << (BOOLEAN_LITERAL - 60)) | (1L << (NUMBER_LITERAL - 60)) | (1L << (STRING_LITERAL - 60)))) != 0))) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3D\u0147\4\2\t\2\4" + + "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t" + + "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22" + + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31" + + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!" + + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\3\2\5\2T\n\2\3" + + "\2\7\2W\n\2\f\2\16\2Z\13\2\3\2\5\2]\n\2\3\2\5\2`\n\2\3\2\5\2c\n\2\3\3" + + "\3\3\5\3g\n\3\3\3\3\3\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\7\3\7\3\7" + + "\3\7\3\7\7\7y\n\7\f\7\16\7|\13\7\3\b\3\b\5\b\u0080\n\b\3\b\5\b\u0083\n" + + "\b\3\t\3\t\3\t\3\t\5\t\u0089\n\t\3\n\3\n\3\13\3\13\3\13\5\13\u0090\n\13" + + "\3\f\3\f\3\f\3\r\3\r\5\r\u0097\n\r\3\r\3\r\5\r\u009b\n\r\3\16\3\16\3\16" + + "\3\16\3\17\3\17\3\17\7\17\u00a4\n\17\f\17\16\17\u00a7\13\17\3\20\3\20" + + "\3\20\5\20\u00ac\n\20\3\21\3\21\3\21\3\22\3\22\3\22\3\23\3\23\5\23\u00b6" + + "\n\23\3\24\3\24\5\24\u00ba\n\24\3\25\3\25\5\25\u00be\n\25\3\26\3\26\3" + + "\26\3\26\3\27\3\27\3\27\7\27\u00c7\n\27\f\27\16\27\u00ca\13\27\3\30\3" + + "\30\3\30\7\30\u00cf\n\30\f\30\16\30\u00d2\13\30\3\31\5\31\u00d5\n\31\3" + + "\31\3\31\3\32\3\32\3\32\3\32\3\32\5\32\u00de\n\32\3\33\3\33\3\33\3\33" + + "\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\5\33\u00ed\n\33\3\34\3\34" + + "\3\34\3\34\3\35\3\35\3\35\3\35\3\35\7\35\u00f8\n\35\f\35\16\35\u00fb\13" + + "\35\3\35\3\35\5\35\u00ff\n\35\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37" + + "\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3 \5 \u0112\n \3!\3!\3!\3!\3!\3!\3!\3" + + "!\5!\u011c\n!\3\"\3\"\3\"\3\"\3\"\5\"\u0123\n\"\3#\3#\3#\3#\3#\3#\3#\3" + + "#\5#\u012d\n#\3$\3$\3$\3$\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\5&\u013d\n&\3" + + "\'\3\'\3(\3(\5(\u0143\n(\3)\3)\3)\2\2*\2\4\6\b\n\f\16\20\22\24\26\30\32" + + "\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNP\2\6\3\2\16\17\3\2$+\3\2,;\4\2" + + ">?CC\u0148\2S\3\2\2\2\4d\3\2\2\2\6l\3\2\2\2\bn\3\2\2\2\np\3\2\2\2\fs\3" + + "\2\2\2\16}\3\2\2\2\20\u0088\3\2\2\2\22\u008a\3\2\2\2\24\u008c\3\2\2\2" + + "\26\u0091\3\2\2\2\30\u0094\3\2\2\2\32\u009c\3\2\2\2\34\u00a0\3\2\2\2\36" + + "\u00ab\3\2\2\2 \u00ad\3\2\2\2\"\u00b0\3\2\2\2$\u00b5\3\2\2\2&\u00b7\3" + + "\2\2\2(\u00bb\3\2\2\2*\u00bf\3\2\2\2,\u00c3\3\2\2\2.\u00cb\3\2\2\2\60" + + "\u00d4\3\2\2\2\62\u00dd\3\2\2\2\64\u00ec\3\2\2\2\66\u00ee\3\2\2\28\u00fe" + + "\3\2\2\2:\u0100\3\2\2\2<\u0106\3\2\2\2>\u0111\3\2\2\2@\u011b\3\2\2\2B" + + "\u0122\3\2\2\2D\u012c\3\2\2\2F\u012e\3\2\2\2H\u0132\3\2\2\2J\u013c\3\2" + + "\2\2L\u013e\3\2\2\2N\u0142\3\2\2\2P\u0144\3\2\2\2RT\5\4\3\2SR\3\2\2\2" + + "ST\3\2\2\2TX\3\2\2\2UW\5\b\5\2VU\3\2\2\2WZ\3\2\2\2XV\3\2\2\2XY\3\2\2\2" + + "Y\\\3\2\2\2ZX\3\2\2\2[]\5\n\6\2\\[\3\2\2\2\\]\3\2\2\2]_\3\2\2\2^`\5\f" + + "\7\2_^\3\2\2\2_`\3\2\2\2`b\3\2\2\2ac\5\24\13\2ba\3\2\2\2bc\3\2\2\2c\3" + + "\3\2\2\2df\7\3\2\2eg\5\6\4\2fe\3\2\2\2fg\3\2\2\2gh\3\2\2\2hi\7\4\2\2i" + + "j\5\34\17\2jk\7\5\2\2k\5\3\2\2\2lm\7\6\2\2m\7\3\2\2\2no\5\30\r\2o\t\3" + + "\2\2\2pq\7\7\2\2qr\5,\27\2r\13\3\2\2\2st\7\b\2\2tu\7\t\2\2uz\5\16\b\2" + + "vw\7\n\2\2wy\5\16\b\2xv\3\2\2\2y|\3\2\2\2zx\3\2\2\2z{\3\2\2\2{\r\3\2\2" + + "\2|z\3\2\2\2}\177\7=\2\2~\u0080\5\22\n\2\177~\3\2\2\2\177\u0080\3\2\2" + + "\2\u0080\u0082\3\2\2\2\u0081\u0083\5\20\t\2\u0082\u0081\3\2\2\2\u0082" + + "\u0083\3\2\2\2\u0083\17\3\2\2\2\u0084\u0085\7\13\2\2\u0085\u0089\7\f\2" + + "\2\u0086\u0087\7\13\2\2\u0087\u0089\7\r\2\2\u0088\u0084\3\2\2\2\u0088" + + "\u0086\3\2\2\2\u0089\21\3\2\2\2\u008a\u008b\t\2\2\2\u008b\23\3\2\2\2\u008c" + + "\u008d\7\20\2\2\u008d\u008f\7?\2\2\u008e\u0090\5\26\f\2\u008f\u008e\3" + + "\2\2\2\u008f\u0090\3\2\2\2\u0090\25\3\2\2\2\u0091\u0092\7\21\2\2\u0092" + + "\u0093\7?\2\2\u0093\27\3\2\2\2\u0094\u0096\7\22\2\2\u0095\u0097\5$\23" + + "\2\u0096\u0095\3\2\2\2\u0096\u0097\3\2\2\2\u0097\u0098\3\2\2\2\u0098\u009a" + + "\7=\2\2\u0099\u009b\5\32\16\2\u009a\u0099\3\2\2\2\u009a\u009b\3\2\2\2" + + "\u009b\31\3\2\2\2\u009c\u009d\7\4\2\2\u009d\u009e\5\34\17\2\u009e\u009f" + + "\7\5\2\2\u009f\33\3\2\2\2\u00a0\u00a5\5\36\20\2\u00a1\u00a2\7\n\2\2\u00a2" + + "\u00a4\5\36\20\2\u00a3\u00a1\3\2\2\2\u00a4\u00a7\3\2\2\2\u00a5\u00a3\3" + + "\2\2\2\u00a5\u00a6\3\2\2\2\u00a6\35\3\2\2\2\u00a7\u00a5\3\2\2\2\u00a8" + + "\u00ac\7=\2\2\u00a9\u00ac\5 \21\2\u00aa\u00ac\5\"\22\2\u00ab\u00a8\3\2" + + "\2\2\u00ab\u00a9\3\2\2\2\u00ab\u00aa\3\2\2\2\u00ac\37\3\2\2\2\u00ad\u00ae" + + "\7\23\2\2\u00ae\u00af\5&\24\2\u00af!\3\2\2\2\u00b0\u00b1\7\23\2\2\u00b1" + + "\u00b2\5(\25\2\u00b2#\3\2\2\2\u00b3\u00b6\5&\24\2\u00b4\u00b6\5(\25\2" + + "\u00b5\u00b3\3\2\2\2\u00b5\u00b4\3\2\2\2\u00b6%\3\2\2\2\u00b7\u00b9\7" + + "\24\2\2\u00b8\u00ba\5*\26\2\u00b9\u00b8\3\2\2\2\u00b9\u00ba\3\2\2\2\u00ba" + + "\'\3\2\2\2\u00bb\u00bd\7\25\2\2\u00bc\u00be\5*\26\2\u00bd\u00bc\3\2\2" + + "\2\u00bd\u00be\3\2\2\2\u00be)\3\2\2\2\u00bf\u00c0\7\4\2\2\u00c0\u00c1" + + "\7?\2\2\u00c1\u00c2\7\5\2\2\u00c2+\3\2\2\2\u00c3\u00c8\5.\30\2\u00c4\u00c5" + + "\7\26\2\2\u00c5\u00c7\5.\30\2\u00c6\u00c4\3\2\2\2\u00c7\u00ca\3\2\2\2" + + "\u00c8\u00c6\3\2\2\2\u00c8\u00c9\3\2\2\2\u00c9-\3\2\2\2\u00ca\u00c8\3" + + "\2\2\2\u00cb\u00d0\5\60\31\2\u00cc\u00cd\7\27\2\2\u00cd\u00cf\5\60\31" + + "\2\u00ce\u00cc\3\2\2\2\u00cf\u00d2\3\2\2\2\u00d0\u00ce\3\2\2\2\u00d0\u00d1" + + "\3\2\2\2\u00d1/\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d3\u00d5\7\30\2\2\u00d4" + + "\u00d3\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d6\3\2\2\2\u00d6\u00d7\5\62" + + "\32\2\u00d7\61\3\2\2\2\u00d8\u00de\5\64\33\2\u00d9\u00da\7\4\2\2\u00da" + + "\u00db\5,\27\2\u00db\u00dc\7\5\2\2\u00dc\u00de\3\2\2\2\u00dd\u00d8\3\2" + + "\2\2\u00dd\u00d9\3\2\2\2\u00de\63\3\2\2\2\u00df\u00ed\5J&\2\u00e0\u00ed" + + "\5F$\2\u00e1\u00ed\5:\36\2\u00e2\u00ed\5<\37\2\u00e3\u00ed\5\66\34\2\u00e4" + + "\u00ed\5> \2\u00e5\u00ed\5@!\2\u00e6\u00ed\5B\"\2\u00e7\u00ed\5D#\2\u00e8" + + "\u00e9\7\4\2\2\u00e9\u00ea\5\64\33\2\u00ea\u00eb\7\5\2\2\u00eb\u00ed\3" + + "\2\2\2\u00ec\u00df\3\2\2\2\u00ec\u00e0\3\2\2\2\u00ec\u00e1\3\2\2\2\u00ec" + + "\u00e2\3\2\2\2\u00ec\u00e3\3\2\2\2\u00ec\u00e4\3\2\2\2\u00ec\u00e5\3\2" + + "\2\2\u00ec\u00e6\3\2\2\2\u00ec\u00e7\3\2\2\2\u00ec\u00e8\3\2\2\2\u00ed" + + "\65\3\2\2\2\u00ee\u00ef\7=\2\2\u00ef\u00f0\7\31\2\2\u00f0\u00f1\58\35" + + "\2\u00f1\67\3\2\2\2\u00f2\u00ff\7<\2\2\u00f3\u00f4\7\4\2\2\u00f4\u00f9" + + "\5N(\2\u00f5\u00f6\7\n\2\2\u00f6\u00f8\5N(\2\u00f7\u00f5\3\2\2\2\u00f8" + + "\u00fb\3\2\2\2\u00f9\u00f7\3\2\2\2\u00f9\u00fa\3\2\2\2\u00fa\u00fc\3\2" + + "\2\2\u00fb\u00f9\3\2\2\2\u00fc\u00fd\7\5\2\2\u00fd\u00ff\3\2\2\2\u00fe" + + "\u00f2\3\2\2\2\u00fe\u00f3\3\2\2\2\u00ff9\3\2\2\2\u0100\u0101\7=\2\2\u0101" + + "\u0102\7\32\2\2\u0102\u0103\5N(\2\u0103\u0104\7\27\2\2\u0104\u0105\5N" + + "(\2\u0105;\3\2\2\2\u0106\u0107\5N(\2\u0107\u0108\7\32\2\2\u0108\u0109" + + "\7=\2\2\u0109\u010a\7\27\2\2\u010a\u010b\7=\2\2\u010b=\3\2\2\2\u010c\u010d" + + "\7=\2\2\u010d\u010e\7\33\2\2\u010e\u0112\7\34\2\2\u010f\u0110\7=\2\2\u0110" + + "\u0112\7\35\2\2\u0111\u010c\3\2\2\2\u0111\u010f\3\2\2\2\u0112?\3\2\2\2" + + "\u0113\u0114\7=\2\2\u0114\u0115\7\33\2\2\u0115\u0116\7\30\2\2\u0116\u011c" + + "\7\34\2\2\u0117\u0118\7=\2\2\u0118\u011c\7\36\2\2\u0119\u011a\7=\2\2\u011a" + + "\u011c\7\37\2\2\u011b\u0113\3\2\2\2\u011b\u0117\3\2\2\2\u011b\u0119\3" + + "\2\2\2\u011cA\3\2\2\2\u011d\u011e\7=\2\2\u011e\u011f\7\33\2\2\u011f\u0123" + + "\7 \2\2\u0120\u0121\7=\2\2\u0121\u0123\7!\2\2\u0122\u011d\3\2\2\2\u0122" + + "\u0120\3\2\2\2\u0123C\3\2\2\2\u0124\u0125\7=\2\2\u0125\u0126\7\33\2\2" + + "\u0126\u0127\7\30\2\2\u0127\u012d\7 \2\2\u0128\u0129\7=\2\2\u0129\u012d" + + "\7\"\2\2\u012a\u012b\7=\2\2\u012b\u012d\7#\2\2\u012c\u0124\3\2\2\2\u012c" + + "\u0128\3\2\2\2\u012c\u012a\3\2\2\2\u012dE\3\2\2\2\u012e\u012f\7=\2\2\u012f" + + "\u0130\5H%\2\u0130\u0131\5N(\2\u0131G\3\2\2\2\u0132\u0133\t\3\2\2\u0133" + + "I\3\2\2\2\u0134\u0135\7=\2\2\u0135\u0136\5L\'\2\u0136\u0137\5N(\2\u0137" + + "\u013d\3\2\2\2\u0138\u0139\5N(\2\u0139\u013a\5L\'\2\u013a\u013b\7=\2\2" + + "\u013b\u013d\3\2\2\2\u013c\u0134\3\2\2\2\u013c\u0138\3\2\2\2\u013dK\3" + + "\2\2\2\u013e\u013f\t\4\2\2\u013fM\3\2\2\2\u0140\u0143\5P)\2\u0141\u0143" + + "\7<\2\2\u0142\u0140\3\2\2\2\u0142\u0141\3\2\2\2\u0143O\3\2\2\2\u0144\u0145" + + "\t\5\2\2\u0145Q\3\2\2\2!SX\\_bfz\177\u0082\u0088\u008f\u0096\u009a\u00a5" + + "\u00ab\u00b5\u00b9\u00bd\u00c8\u00d0\u00d4\u00dd\u00ec\u00f9\u00fe\u0111" + + "\u011b\u0122\u012c\u013c\u0142"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/idgen/package.html b/src/main/java/com/avaje/ebeaninternal/server/idgen/package.html index 6e97437be..90aa57569 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/idgen/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/idgen/package.html @@ -1,11 +1,11 @@ - - Id Generation + + Id Generation Id Generation (Sequences, UUIDGen etc) - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonScheduleThreadPool.java b/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonScheduleThreadPool.java index f420e59d2..0e45a8caf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonScheduleThreadPool.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonScheduleThreadPool.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.lib; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + /** * Daemon based ScheduleThreadPool. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonThreadFactory.java b/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonThreadFactory.java index 70ca67fe5..63dc82944 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonThreadFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonThreadFactory.java @@ -15,35 +15,35 @@ import java.util.concurrent.atomic.AtomicInteger; * on shutdown or register with the JVM shutdown hook to perform a nice shutdown * of the daemon threads etc. *

- * + * * @author rbygrave */ public class DaemonThreadFactory implements ThreadFactory { - private static final AtomicInteger poolNumber = new AtomicInteger(1); - - private final ThreadGroup group; - - private final AtomicInteger threadNumber = new AtomicInteger(1); - - private final String namePrefix; + private static final AtomicInteger poolNumber = new AtomicInteger(1); - public DaemonThreadFactory(String namePrefix) { - SecurityManager s = System.getSecurityManager(); - this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); - this.namePrefix = namePrefix != null ? namePrefix : "pool-" + poolNumber.getAndIncrement() + "-thread-"; + private final ThreadGroup group; + + private final AtomicInteger threadNumber = new AtomicInteger(1); + + private final String namePrefix; + + public DaemonThreadFactory(String namePrefix) { + SecurityManager s = System.getSecurityManager(); + this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); + this.namePrefix = namePrefix != null ? namePrefix : "pool-" + poolNumber.getAndIncrement() + "-thread-"; + } + + public Thread newThread(Runnable r) { + + Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); + + t.setDaemon(true); + + if (t.getPriority() != Thread.NORM_PRIORITY) { + t.setPriority(Thread.NORM_PRIORITY); } - public Thread newThread(Runnable r) { - - Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); - - t.setDaemon(true); - - if (t.getPriority() != Thread.NORM_PRIORITY) { - t.setPriority(Thread.NORM_PRIORITY); - } - - return t; - } -} \ No newline at end of file + return t; + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java b/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java index 8100e6816..892a36e9c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java @@ -21,87 +21,87 @@ import java.util.List; */ public final class ShutdownManager { - private static final Logger logger = LoggerFactory.getLogger(ShutdownManager.class); + private static final Logger logger = LoggerFactory.getLogger(ShutdownManager.class); - static final List servers = new ArrayList(); + static final List servers = new ArrayList<>(); - static final ShutdownHook shutdownHook = new ShutdownHook(); + static final ShutdownHook shutdownHook = new ShutdownHook(); - static boolean stopping; + static boolean stopping; - static SpiContainer container; + static SpiContainer container; - static { - // Register the Shutdown hook - registerShutdownHook(); - } + static { + // Register the Shutdown hook + registerShutdownHook(); + } - /** - * Disallow construction. - */ - private ShutdownManager() { - } + /** + * Disallow construction. + */ + private ShutdownManager() { + } - public static void registerContainer(SpiContainer ebeanContainer){ - container = ebeanContainer; - } - - /** - * Make sure the ShutdownManager is activated. - */ - public static void touch() { - // Do nothing - } + public static void registerContainer(SpiContainer ebeanContainer) { + container = ebeanContainer; + } - /** - * Return true if the system is in the process of stopping. - */ - public static boolean isStopping() { - synchronized (servers) { - return stopping; - } - } + /** + * Make sure the ShutdownManager is activated. + */ + public static void touch() { + // Do nothing + } - /** - * Deregister the Shutdown hook. + /** + * Return true if the system is in the process of stopping. + */ + public static boolean isStopping() { + synchronized (servers) { + return stopping; + } + } + + /** + * Deregister the Shutdown hook. *

* In calling this method it is expected that application code will invoke * the shutdown() method. *

- *

- * For running in a Servlet Container a redeploy will cause a shutdown, and - * for that case we need to make sure the shutdown hook is deregistered. - *

- */ - public static void deregisterShutdownHook() { - synchronized (servers) { - try { - Runtime.getRuntime().removeShutdownHook(shutdownHook); - } catch (IllegalStateException ex) { - if (!ex.getMessage().equals("Shutdown in progress")) { - throw ex; - } - } - } - } + *

+ * For running in a Servlet Container a redeploy will cause a shutdown, and + * for that case we need to make sure the shutdown hook is deregistered. + *

+ */ + public static void deregisterShutdownHook() { + synchronized (servers) { + try { + Runtime.getRuntime().removeShutdownHook(shutdownHook); + } catch (IllegalStateException ex) { + if (!ex.getMessage().equals("Shutdown in progress")) { + throw ex; + } + } + } + } - /** - * Register the shutdown hook with the Runtime. - */ - protected static void registerShutdownHook() { - synchronized (servers) { - try { + /** + * Register the shutdown hook with the Runtime. + */ + protected static void registerShutdownHook() { + synchronized (servers) { + try { String value = System.getProperty("ebean.registerShutdownHook"); if (value == null || !value.trim().equalsIgnoreCase("false")) { Runtime.getRuntime().addShutdownHook(shutdownHook); } - } catch (IllegalStateException ex) { - if (!ex.getMessage().equals("Shutdown in progress")) { - throw ex; - } - } - } - } + } catch (IllegalStateException ex) { + if (!ex.getMessage().equals("Shutdown in progress")) { + throw ex; + } + } + } + } /** * Shutdown gracefully cleaning up any resources as required. @@ -134,7 +134,7 @@ public final class ShutdownManager { logger.error("Error running custom shutdown runnable", e); } } - + if (container != null) { // shutdown cluster networking if active container.shutdown(); @@ -150,10 +150,10 @@ public final class ShutdownManager { ex.printStackTrace(); } } - + if ("true".equalsIgnoreCase(System.getProperty("ebean.datasource.deregisterAllDrivers", "false"))) { deregisterAllJdbcDrivers(); - } + } } } @@ -163,29 +163,29 @@ public final class ShutdownManager { while (drivers.hasMoreElements()) { Driver driver = drivers.nextElement(); try { - logger.info("Deregistering jdbc driver: "+driver); + logger.info("Deregistering jdbc driver: " + driver); DriverManager.deregisterDriver(driver); } catch (SQLException e) { - logger.error("Error deregistering driver "+driver, e); + logger.error("Error deregistering driver " + driver, e); } } } - - /** - * Register an ebeanServer to be shutdown when the JVM is shutdown. - */ - public static void registerEbeanServer(SpiEbeanServer server) { - synchronized (servers) { - servers.add(server); - } - } - - /** - * Deregister an ebeanServer. - *

- * This is done when the ebeanServer is shutdown manually. - *

- */ + + /** + * Register an ebeanServer to be shutdown when the JVM is shutdown. + */ + public static void registerEbeanServer(SpiEbeanServer server) { + synchronized (servers) { + servers.add(server); + } + } + + /** + * Deregister an ebeanServer. + *

+ * This is done when the ebeanServer is shutdown manually. + *

+ */ public static void unregisterEbeanServer(SpiEbeanServer server) { synchronized (servers) { servers.remove(server); diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/package.html b/src/main/java/com/avaje/ebeaninternal/server/lib/package.html index 9055f2795..a114cce65 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/package.html @@ -1,13 +1,13 @@ - - AvajeLib + + AvajeLib Core services for an application.

-Core services including Logging, Deployment properties and Background thread for -running frequent tasks. + Core services including Logging, Deployment properties and Background thread for + running frequent tasks.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java index e6521da23..6e7cfce48 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java @@ -10,23 +10,23 @@ public class Str { /** * Append strings together. */ - public static String add(String s0, String s1, String ... args) { - + public static String add(String s0, String s1, String... args) { + // determine a decent buffer size int len = 16 + s0.length() + s1.length(); - for (int i = 0; i < args.length; i++) { - len += args[i].length(); + for (String arg1 : args) { + len += arg1.length(); } - - // append all the strings into the buffer + + // append all the strings into the buffer StringBuilder sb = new StringBuilder(len); sb.append(s0).append(s1); - for (int i = 0; i < args.length; i++) { - sb.append(args[i]); + for (String arg : args) { + sb.append(arg); } return sb.toString(); } - + /** * Append two strings together. */ @@ -35,5 +35,5 @@ public class Str { StringBuilder sb = new StringBuilder(s0.length() + s1.length() + 5); return sb.append(s0).append(s1).toString(); } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java index b3bb630e2..ca008eb7c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java @@ -8,293 +8,285 @@ import java.util.Map; */ public class StringHelper { - /** - * Parses out a list of Name Value pairs that are delimited together. Will - * always return a StringMap. If allNameValuePairs is null, or no name - * values can be parsed out an empty StringMap is returned. - * - * @param allNameValuePairs - * the entire string to be parsed. - * @param listDelimiter - * (typically ';') the delimited between the list - * @param nameValueSeparator - * (typically '=') the separator between the name and value - */ - public static Map delimitedToMap(String allNameValuePairs, - String listDelimiter, String nameValueSeparator) { + /** + * Parses out a list of Name Value pairs that are delimited together. Will + * always return a StringMap. If allNameValuePairs is null, or no name + * values can be parsed out an empty StringMap is returned. + * + * @param allNameValuePairs the entire string to be parsed. + * @param listDelimiter (typically ';') the delimited between the list + * @param nameValueSeparator (typically '=') the separator between the name and value + */ + public static Map delimitedToMap(String allNameValuePairs, + String listDelimiter, String nameValueSeparator) { - HashMap params = new HashMap(); - if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) { - return params; - } - // trim off any leading listDelimiter... - allNameValuePairs = trimFront(allNameValuePairs, listDelimiter); - return getKeyValue(params, 0, allNameValuePairs, listDelimiter, nameValueSeparator); - } + HashMap params = new HashMap<>(); + if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) { + return params; + } + // trim off any leading listDelimiter... + allNameValuePairs = trimFront(allNameValuePairs, listDelimiter); + return getKeyValue(params, 0, allNameValuePairs, listDelimiter, nameValueSeparator); + } - /** - * Trims off recurring strings from the front of a string. - * - * @param source - * the source string - * @param trim - * the string to trim off the front - */ - public static String trimFront(String source, String trim) { - if (source == null) { - return null; - } - if (source.indexOf(trim) == 0) { - // dp("trim ..."); - return trimFront(source.substring(trim.length()), trim); - } else { - return source; - } - } + /** + * Trims off recurring strings from the front of a string. + * + * @param source the source string + * @param trim the string to trim off the front + */ + public static String trimFront(String source, String trim) { + if (source == null) { + return null; + } + if (source.indexOf(trim) == 0) { + // dp("trim ..."); + return trimFront(source.substring(trim.length()), trim); + } else { + return source; + } + } - /** - * Return true if the value is null or an empty string. - */ - public static boolean isNull(String value) { + /** + * Return true if the value is null or an empty string. + */ + public static boolean isNull(String value) { return value == null || value.trim().isEmpty(); } - /** - * Recursively pulls out the key value pairs from a raw string. - */ - private static HashMap getKeyValue(HashMap map, int pos, - String allNameValuePairs, String listDelimiter, String nameValueSeparator) { + /** + * Recursively pulls out the key value pairs from a raw string. + */ + private static HashMap getKeyValue(HashMap map, int pos, + String allNameValuePairs, String listDelimiter, String nameValueSeparator) { - if (pos >= allNameValuePairs.length()) { - // dp("end as "+pos+" >= "+allNameValuePairs.length() ); - return map; - } + if (pos >= allNameValuePairs.length()) { + // dp("end as "+pos+" >= "+allNameValuePairs.length() ); + return map; + } - int equalsPos = allNameValuePairs.indexOf(nameValueSeparator, pos); - int delimPos = allNameValuePairs.indexOf(listDelimiter, pos); + int equalsPos = allNameValuePairs.indexOf(nameValueSeparator, pos); + int delimPos = allNameValuePairs.indexOf(listDelimiter, pos); - if (delimPos == -1) { - delimPos = allNameValuePairs.length(); - } - if (equalsPos == -1) { - // dp("no more equals..."); - return map; - } - if (delimPos == (equalsPos + 1)) { - // dp("Ignoring as nothing between delim and equals... - // delim:"+delimPos+" eq:"+equalsPos); - return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, - nameValueSeparator); - } - if (equalsPos > delimPos) { - // there is a key without a value? - String key = allNameValuePairs.substring(pos, delimPos); - key = key.trim(); - if (!key.isEmpty()) { - map.put(key, null); - } - return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, - nameValueSeparator); + if (delimPos == -1) { + delimPos = allNameValuePairs.length(); + } + if (equalsPos == -1) { + // dp("no more equals..."); + return map; + } + if (delimPos == (equalsPos + 1)) { + // dp("Ignoring as nothing between delim and equals... + // delim:"+delimPos+" eq:"+equalsPos); + return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, + nameValueSeparator); + } + if (equalsPos > delimPos) { + // there is a key without a value? + String key = allNameValuePairs.substring(pos, delimPos); + key = key.trim(); + if (!key.isEmpty()) { + map.put(key, null); + } + return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, + nameValueSeparator); - } - String key = allNameValuePairs.substring(pos, equalsPos); + } + String key = allNameValuePairs.substring(pos, equalsPos); - if (delimPos > -1) { - String value = allNameValuePairs.substring(equalsPos + 1, delimPos); - // dp("cont "+key+","+value+" pos:"+pos+" - // len:"+allNameValuePairs.length()); - key = key.trim(); + if (delimPos > -1) { + String value = allNameValuePairs.substring(equalsPos + 1, delimPos); + // dp("cont "+key+","+value+" pos:"+pos+" + // len:"+allNameValuePairs.length()); + key = key.trim(); - map.put(key, value); - pos = delimPos + 1; + map.put(key, value); + pos = delimPos + 1; - // recurse the rest of the values... - return getKeyValue(map, pos, allNameValuePairs, listDelimiter, nameValueSeparator); - } else { - // dp("ERROR: delimPos < 0 ???"); - return map; - } - } + // recurse the rest of the values... + return getKeyValue(map, pos, allNameValuePairs, listDelimiter, nameValueSeparator); + } else { + // dp("ERROR: delimPos < 0 ???"); + return map; + } + } - /** - * This method takes a String and will replace all occurrences of the match - * String with that of the replace String. - * - * @param source - * the source string - * @param match - * the string used to find a match - * @param replace - * the string used to replace match with - * @return the source string after the search and replace - */ - public static String replaceString(String source, String match, String replace) { - if (source == null){ - return null; - } - if (replace == null){ - return source; - } - if (match == null){ - throw new NullPointerException("match is null?"); - } - if (match.equals(replace)){ - return source; - } - return replaceString(source, match, replace, 30, 0, source.length()); - } + /** + * This method takes a String and will replace all occurrences of the match + * String with that of the replace String. + * + * @param source the source string + * @param match the string used to find a match + * @param replace the string used to replace match with + * @return the source string after the search and replace + */ + public static String replaceString(String source, String match, String replace) { + if (source == null) { + return null; + } + if (replace == null) { + return source; + } + if (match == null) { + throw new NullPointerException("match is null?"); + } + if (match.equals(replace)) { + return source; + } + return replaceString(source, match, replace, 30, 0, source.length()); + } - /** - * Additionally specify the additionalSize to add to the buffer. This will - * make the buffer bigger so that it doesn't have to grow when replacement - * occurs. - */ - public static String replaceString(String source, String match, String replace, - int additionalSize, int startPos, int endPos) { + /** + * Additionally specify the additionalSize to add to the buffer. This will + * make the buffer bigger so that it doesn't have to grow when replacement + * occurs. + */ + public static String replaceString(String source, String match, String replace, + int additionalSize, int startPos, int endPos) { - if (source == null){ - return null; - } - - char match0 = match.charAt(0); - - int matchLength = match.length(); + if (source == null) { + return null; + } - if (matchLength == 1 && replace.length() == 1) { - char replace0 = replace.charAt(0); - return source.replace(match0, replace0); - } - if (matchLength >= replace.length()) { - additionalSize = 0; - } + char match0 = match.charAt(0); + + int matchLength = match.length(); + + if (matchLength == 1 && replace.length() == 1) { + char replace0 = replace.charAt(0); + return source.replace(match0, replace0); + } + if (matchLength >= replace.length()) { + additionalSize = 0; + } - int sourceLength = source.length(); - int lastMatch = endPos - matchLength; + int sourceLength = source.length(); + int lastMatch = endPos - matchLength; - StringBuilder sb = new StringBuilder(sourceLength + additionalSize); + StringBuilder sb = new StringBuilder(sourceLength + additionalSize); - if (startPos > 0) { - sb.append(source.substring(0, startPos)); - } + if (startPos > 0) { + sb.append(source.substring(0, startPos)); + } - char sourceChar; - boolean isMatch; - int sourceMatchPos; + char sourceChar; + boolean isMatch; + int sourceMatchPos; - for (int i = startPos; i < sourceLength; i++) { - sourceChar = source.charAt(i); - if (i > lastMatch || sourceChar != match0) { - sb.append(sourceChar); + for (int i = startPos; i < sourceLength; i++) { + sourceChar = source.charAt(i); + if (i > lastMatch || sourceChar != match0) { + sb.append(sourceChar); - } else { - // check to see if this is a match - isMatch = true; - sourceMatchPos = i; - - // check each following character... - for (int j = 1; j < matchLength; j++) { - sourceMatchPos++; - if (source.charAt(sourceMatchPos) != match.charAt(j)) { - isMatch = false; - break; - } - } - if (isMatch) { - i = i + matchLength - 1; - sb.append(replace); - } else { - // was not a match - sb.append(sourceChar); - } - } - } + } else { + // check to see if this is a match + isMatch = true; + sourceMatchPos = i; - return sb.toString(); - } + // check each following character... + for (int j = 1; j < matchLength; j++) { + sourceMatchPos++; + if (source.charAt(sourceMatchPos) != match.charAt(j)) { + isMatch = false; + break; + } + } + if (isMatch) { + i = i + matchLength - 1; + sb.append(replace); + } else { + // was not a match + sb.append(sourceChar); + } + } + } - /** - * A search and replace with multiple matching strings. - *

- * Useful when converting CRNL CR and NL all to a BR tag for example. - *

- * - *

-	 * String[] multi = { "\r\n", "\r", "\n" };
-	 * content = StringHelper.replaceStringMulti(content, multi, "<br/>");
-	 * 
- */ - public static String replaceStringMulti(String source, String[] match, String replace) { - return replaceStringMulti(source, match, replace, 30, 0, source.length()); - } + return sb.toString(); + } - /** - * Additionally specify an additional size estimate for the buffer plus - * start and end positions. - *

- * The start and end positions can limit the search and replace. Otherwise - * these default to startPos = 0 and endPos = source.length(). - *

- */ - public static String replaceStringMulti(String source, String[] match, String replace, - int additionalSize, int startPos, int endPos) { + /** + * A search and replace with multiple matching strings. + *

+ * Useful when converting CRNL CR and NL all to a BR tag for example. + *

+ *

+ *


+   * String[] multi = { "\r\n", "\r", "\n" };
+   * content = StringHelper.replaceStringMulti(content, multi, "<br/>");
+   * 
+ */ + public static String replaceStringMulti(String source, String[] match, String replace) { + return replaceStringMulti(source, match, replace, 30, 0, source.length()); + } - int shortestMatch = match[0].length(); + /** + * Additionally specify an additional size estimate for the buffer plus + * start and end positions. + *

+ * The start and end positions can limit the search and replace. Otherwise + * these default to startPos = 0 and endPos = source.length(). + *

+ */ + public static String replaceStringMulti(String source, String[] match, String replace, + int additionalSize, int startPos, int endPos) { - char[] match0 = new char[match.length]; - for (int i = 0; i < match0.length; i++) { - match0[i] = match[i].charAt(0); - if (match[i].length() < shortestMatch) { - shortestMatch = match[i].length(); - } - } + int shortestMatch = match[0].length(); - StringBuilder sb = new StringBuilder(source.length() + additionalSize); + char[] match0 = new char[match.length]; + for (int i = 0; i < match0.length; i++) { + match0[i] = match[i].charAt(0); + if (match[i].length() < shortestMatch) { + shortestMatch = match[i].length(); + } + } - char sourceChar; + StringBuilder sb = new StringBuilder(source.length() + additionalSize); - int len = source.length(); - int lastMatch = endPos - shortestMatch; + char sourceChar; - if (startPos > 0) { - sb.append(source.substring(0, startPos)); - } + int len = source.length(); + int lastMatch = endPos - shortestMatch; - int matchCount; + if (startPos > 0) { + sb.append(source.substring(0, startPos)); + } - for (int i = startPos; i < len; i++) { - sourceChar = source.charAt(i); - if (i > lastMatch) { - sb.append(sourceChar); - } else { - matchCount = 0; - for (int k = 0; k < match0.length; k++) { - if (matchCount == 0 && sourceChar == match0[k]) { - if (match[k].length() + i <= len) { + int matchCount; - ++matchCount; - int j = 1; - for (; j < match[k].length(); j++) { - if (source.charAt(i + j) != match[k].charAt(j)) { - --matchCount; - break; - } - } - if (matchCount > 0) { - i = i + j - 1; - sb.append(replace); - break; - } - } - } - } - if (matchCount == 0) { - sb.append(sourceChar); - } - } - } + for (int i = startPos; i < len; i++) { + sourceChar = source.charAt(i); + if (i > lastMatch) { + sb.append(sourceChar); + } else { + matchCount = 0; + for (int k = 0; k < match0.length; k++) { + if (matchCount == 0 && sourceChar == match0[k]) { + if (match[k].length() + i <= len) { - return sb.toString(); - } + ++matchCount; + int j = 1; + for (; j < match[k].length(); j++) { + if (source.charAt(i + j) != match[k].charAt(j)) { + --matchCount; + break; + } + } + if (matchCount > 0) { + i = i + j - 1; + sb.append(replace); + break; + } + } + } + } + if (matchCount == 0) { + sb.append(sourceChar); + } + } + } + + return sb.toString(); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/package.html b/src/main/java/com/avaje/ebeaninternal/server/lib/util/package.html index 5079d4e5b..4f128ef71 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/package.html @@ -1,7 +1,7 @@ - - AvajeLib + + AvajeLib General utility objects. @@ -9,4 +9,4 @@ General utility objects.

Provides general utility objects.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadBeanContext.java b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadBeanContext.java index 3a73be4e3..c1f374bb1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadBeanContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadBeanContext.java @@ -27,7 +27,7 @@ public class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContex public DLoadBeanContext(DLoadContext parent, BeanDescriptor desc, String path, int defaultBatchSize, OrmQueryProperties queryProps) { super(parent, desc, path, defaultBatchSize, queryProps); // bufferList only required when using query joins (queryFetch) - this.bufferList = (!queryFetch) ? null : new ArrayList(); + this.bufferList = (!queryFetch) ? null : new ArrayList<>(); this.currentBuffer = createBuffer(firstBatchSize); } @@ -109,7 +109,7 @@ public class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContex public LoadBuffer(DLoadBeanContext context, int batchSize) { this.context = context; this.batchSize = batchSize; - this.list = new ArrayList(batchSize); + this.list = new ArrayList<>(batchSize); } public int getBatchSize() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java index 2088e5b05..31159abad 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java @@ -33,8 +33,8 @@ public class DLoadContext implements LoadContext { private final BeanDescriptor rootDescriptor; - private final Map beanMap = new HashMap(); - private final Map manyMap = new HashMap(); + private final Map beanMap = new HashMap<>(); + private final Map manyMap = new HashMap<>(); private final DLoadBeanContext rootBeanContext; @@ -55,7 +55,7 @@ public class DLoadContext implements LoadContext { private final ObjectGraphOrigin origin; private final boolean useProfiling; - private final Map nodePathMap = new HashMap(); + private final Map nodePathMap = new HashMap<>(); private PersistenceContext persistenceContext; @@ -169,8 +169,8 @@ public class DLoadContext implements LoadContext { } int maxBatch = 0; - for (int i = 0; i < secQuery.size(); i++) { - int batchSize = secQuery.get(i).getQueryFetchBatch(); + for (OrmQueryProperties aSecQuery : secQuery) { + int batchSize = aSecQuery.getQueryFetchBatch(); if (batchSize == 0) { batchSize = defaultQueryBatch; } @@ -185,8 +185,8 @@ public class DLoadContext implements LoadContext { public void executeSecondaryQueries(OrmQueryRequest parentRequest, boolean forEach) { if (secQuery != null) { - for (int i = 0; i < secQuery.size(); i++) { - LoadSecondaryQuery load = getLoadSecondaryQuery(secQuery.get(i).getPath()); + for (OrmQueryProperties aSecQuery : secQuery) { + LoadSecondaryQuery load = getLoadSecondaryQuery(aSecQuery.getPath()); load.loadSecondaryQuery(parentRequest, forEach); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadManyContext.java b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadManyContext.java index 979244593..b55b1efe4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadManyContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadManyContext.java @@ -35,7 +35,7 @@ public class DLoadManyContext extends DLoadBaseContext implements LoadManyContex this.property = property; this.docStoreMapped = property.getTargetDescriptor().isDocStoreMapped(); // bufferList only required when using query joins (queryFetch) - this.bufferList = (!queryFetch) ? null : new ArrayList(); + this.bufferList = (!queryFetch) ? null : new ArrayList<>(); this.currentBuffer = createBuffer(firstBatchSize); } @@ -133,7 +133,7 @@ public class DLoadManyContext extends DLoadBaseContext implements LoadManyContex // case it changes as part of a findIterate etc this.persistenceContext = context.getPersistenceContext(); this.batchSize = batchSize; - this.list = new ArrayList>(batchSize); + this.list = new ArrayList<>(batchSize); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java index 846ed3dd2..3242809af 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java @@ -1,16 +1,15 @@ package com.avaje.ebeaninternal.server.persist; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; - -import javax.persistence.PersistenceException; - import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import javax.persistence.PersistenceException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; + /** * Controls the batch ordering of persist requests. *

@@ -42,7 +41,7 @@ public final class BatchControl { * Map of the BatchedBeanHolder objects. They each have a depth and are later * sorted by their depth to get the execution order. */ - private final HashMap beanHoldMap = new HashMap(); + private final HashMap beanHoldMap = new HashMap<>(); private final SpiTransaction transaction; @@ -226,6 +225,14 @@ public final class BatchControl { flush(true); } + /** + * Clears the batch, discarding all batched statements. + */ + public void clear() { + pstmtHolder.clear(); + beanHoldMap.clear(); + } + /** * execute all the requests currently queued or batched. */ @@ -248,8 +255,8 @@ public final class BatchControl { if (transaction.isLogSummary()) { transaction.logSummary("BatchControl flush " + Arrays.toString(bsArray)); } - for (int i = 0; i < bsArray.length; i++) { - bsArray[i].executeNow(); + for (BatchedBeanHolder aBsArray : bsArray) { + aBsArray.executeNow(); } if (resetTop) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedBeanHolder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedBeanHolder.java index df18d3a93..e842c52eb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedBeanHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedBeanHolder.java @@ -54,7 +54,7 @@ public class BatchedBeanHolder { * Set of beans in this batch. This is used to ensure that a single bean instance is not included * in the batch twice (two separate insert requests etc). */ - private final IdentityHashMap persistedBeans = new IdentityHashMap(); + private final IdentityHashMap persistedBeans = new IdentityHashMap<>(); /** * Create a new entry with a given type and depth. @@ -132,7 +132,7 @@ public class BatchedBeanHolder { switch (request.getType()) { case INSERT: if (inserts == null) { - inserts = new ArrayList(); + inserts = new ArrayList<>(); } inserts.add(request); return inserts.size(); @@ -140,14 +140,14 @@ public class BatchedBeanHolder { case UPDATE: case SOFT_DELETE: if (updates == null) { - updates = new ArrayList(); + updates = new ArrayList<>(); } updates.add(request); return updates.size(); case DELETE: if (deletes == null) { - deletes = new ArrayList(); + deletes = new ArrayList<>(); } deletes.add(request); return deletes.size(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java index c2c808ea7..999bf4ef8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java @@ -27,7 +27,7 @@ public class BatchedPstmt { /** * The list of BatchPostExecute used to perform post processing. */ - private final ArrayList list = new ArrayList(); + private final ArrayList list = new ArrayList<>(); private final String sql; @@ -93,8 +93,8 @@ public class BatchedPstmt { } private void postExecute() { - for (int i = 0; i < list.size(); i++) { - list.get(i).postExecute(); + for (BatchPostExecute aList : list) { + aList.postExecute(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java index 2f682e215..1cc374303 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java @@ -1,14 +1,13 @@ package com.avaje.ebeaninternal.server.persist; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.LinkedHashMap; - -import javax.persistence.PersistenceException; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.LinkedHashMap; + /** * Used to hold BatchedPstmt objects for batch based execution. *

@@ -25,7 +24,7 @@ public class BatchedPstmtHolder { * A Map of the statements using a String key. This is used so that the same * Statement,Prepared,Callable is reused. */ - private final LinkedHashMap stmtMap = new LinkedHashMap(); + private final LinkedHashMap stmtMap = new LinkedHashMap<>(); /** * The Max size across all the BatchedPstmt. @@ -119,8 +118,7 @@ public class BatchedPstmtHolder { } // clear the batch cache - stmtMap.clear(); - maxSize = 0; + clear(); if (firstError != null) { String msg = "Error when batch flush on sql: " + errorSql; @@ -128,6 +126,11 @@ public class BatchedPstmtHolder { } } + public void clear() { + stmtMap.clear(); + maxSize = 0; + } + /** * Return the size of the biggest batched statement. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BeanPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BeanPersister.java index 96f75ab7f..c4e192288 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BeanPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BeanPersister.java @@ -1,9 +1,9 @@ package com.avaje.ebeaninternal.server.persist; -import javax.persistence.PersistenceException; - import com.avaje.ebeaninternal.server.core.PersistRequestBean; +import javax.persistence.PersistenceException; + /** * Defines bean insert update and delete implementation. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BindValues.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BindValues.java index bb41fd74b..8bf946244 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BindValues.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BindValues.java @@ -7,7 +7,7 @@ import java.util.ArrayList; */ public class BindValues { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); /** * Create with a Binder. diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java index f9e329562..4049b26a0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java @@ -1,16 +1,5 @@ package com.avaje.ebeaninternal.server.persist; -import java.math.BigDecimal; -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Types; -import java.util.ArrayList; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.config.dbplatform.DbPlatformType; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.server.core.DbExpressionHandler; @@ -22,6 +11,16 @@ import com.avaje.ebeaninternal.server.type.TypeManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import java.math.BigDecimal; +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import java.util.List; + /** * Binds bean values to a PreparedStatement. */ @@ -74,9 +73,7 @@ public class Binder { String logPrefix = ""; ArrayList list = bindValues.values(); - for (int i = 0; i < list.size(); i++) { - BindValues.Value bindValue = list.get(i); - + for (BindValues.Value bindValue : list) { Object val = bindValue.getValue(); int dt = bindValue.getDbType(); bindObject(dataBind, val, dt); @@ -136,9 +133,7 @@ public class Binder { // the iterator is assumed to be in the correct order Object value = null; try { - for (int i = 0; i < list.size(); i++) { - - BindParams.Param param = list.get(i); + for (BindParams.Param param : list) { if (param.isOutParam() && cstmt != null) { cstmt.registerOutParameter(dataBind.nextPos(), param.getType()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java index 7883d169e..f676bc153 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java @@ -136,7 +136,7 @@ public final class DefaultPersister implements Persister { Class beanType = query.getBeanType(); BeanDescriptor desc = server.getBeanDescriptor(beanType); - DraftHandler draftHandler = new DraftHandler(desc, transaction); + DraftHandler draftHandler = new DraftHandler<>(desc, transaction); List liveBeans = draftHandler.fetchSourceBeans(query, false); PUB.debug("draftRestore [{}] count[{}]", desc.getName(), liveBeans.size()); @@ -148,7 +148,7 @@ public final class DefaultPersister implements Persister { BeanManager mgr = beanDescriptorManager.getBeanManager(beanType); - for (T liveBean: liveBeans) { + for (T liveBean : liveBeans) { T draftBean = draftHandler.publishToDestinationBean(liveBean); // reset @DraftDirty and @DraftReset properties draftHandler.resetDraft(draftBean); @@ -165,8 +165,8 @@ public final class DefaultPersister implements Persister { * Helper method to return the list of Id values for the list of beans. */ private List getBeanIds(BeanDescriptor desc, List beans) { - List idList = new ArrayList(); - for (T liveBean: beans) { + List idList = new ArrayList<>(); + for (T liveBean : beans) { idList.add(desc.getBeanId(liveBean)); } return idList; @@ -181,7 +181,7 @@ public final class DefaultPersister implements Persister { Class beanType = query.getBeanType(); BeanDescriptor desc = server.getBeanDescriptor(beanType); - DraftHandler draftHandler = new DraftHandler(desc, transaction); + DraftHandler draftHandler = new DraftHandler<>(desc, transaction); List draftBeans = draftHandler.fetchSourceBeans(query, true); PUB.debug("publish [{}] count[{}]", desc.getName(), draftBeans.size()); @@ -193,11 +193,11 @@ public final class DefaultPersister implements Persister { BeanManager mgr = beanDescriptorManager.getBeanManager(beanType); - List livePublish = new ArrayList(draftBeans.size()); - for (T draftBean: draftBeans) { + List livePublish = new ArrayList<>(draftBeans.size()); + for (T draftBean : draftBeans) { T liveBean = draftHandler.publishToDestinationBean(draftBean); livePublish.add(liveBean); - + // reset @DraftDirty and @DraftReset properties draftHandler.resetDraft(draftBean); @@ -226,7 +226,7 @@ public final class DefaultPersister implements Persister { final BeanDescriptor desc; final Transaction transaction; final BeanProperty draftDirty; - final List draftUpdates = new ArrayList(); + final List draftUpdates = new ArrayList<>(); /** * Id value of the last published bean. @@ -557,8 +557,8 @@ public final class DefaultPersister implements Persister { } private void deleteList(List beanList, Transaction t, boolean softDelete) { - for (int i = 0; i < beanList.size(); i++) { - deleteRecurse((EntityBean) beanList.get(i), t, softDelete); + for (Object aBeanList : beanList) { + deleteRecurse((EntityBean) aBeanList, t, softDelete); } } @@ -573,7 +573,7 @@ public final class DefaultPersister implements Persister { BeanDescriptor descriptor = beanDescriptorManager.getBeanDescriptor(beanType); - ArrayList idList = new ArrayList(ids.size()); + ArrayList idList = new ArrayList<>(ids.size()); for (Object id : ids) { // convert to appropriate type if required idList.add(descriptor.convertId(id)); @@ -634,15 +634,15 @@ public final class DefaultPersister implements Persister { if (t.isPersistCascade()) { // OneToOne exported side with delete cascade BeanPropertyAssocOne[] expOnes = descriptor.propertiesOneExportedDelete(); - for (int i = 0; i < expOnes.length; i++) { - BeanDescriptor targetDesc = expOnes[i].getTargetDescriptor(); + for (BeanPropertyAssocOne expOne : expOnes) { + BeanDescriptor targetDesc = expOne.getTargetDescriptor(); // only cascade soft deletes when supported by target if (!softDelete || targetDesc.isSoftDelete()) { if (!softDelete && targetDesc.isDeleteByStatement()) { - SqlUpdate sqlDelete = expOnes[i].deleteByParentId(id, idList); + SqlUpdate sqlDelete = expOne.deleteByParentId(id, idList); executeSqlUpdate(sqlDelete, t); } else { - List childIds = expOnes[i].findIdsByParentId(id, idList, t); + List childIds = expOne.findIdsByParentId(id, idList, t); deleteChildrenById(t, targetDesc, childIds, softDelete); } } @@ -650,17 +650,17 @@ public final class DefaultPersister implements Persister { // OneToMany's with delete cascade BeanPropertyAssocMany[] manys = descriptor.propertiesManyDelete(); - for (int i = 0; i < manys.length; i++) { - BeanDescriptor targetDesc = manys[i].getTargetDescriptor(); + for (BeanPropertyAssocMany many : manys) { + BeanDescriptor targetDesc = many.getTargetDescriptor(); // only cascade soft deletes when supported by target if (!softDelete || targetDesc.isSoftDelete()) { if (!softDelete && targetDesc.isDeleteByStatement()) { // we can just delete children with a single statement - SqlUpdate sqlDelete = manys[i].deleteByParentId(id, idList); + SqlUpdate sqlDelete = many.deleteByParentId(id, idList); executeSqlUpdate(sqlDelete, t); } else { // we need to fetch the Id's to delete (recurse or notify L2 cache) - List childIds = manys[i].findIdsByParentId(id, idList, t, null); + List childIds = many.findIdsByParentId(id, idList, t, null); if (!childIds.isEmpty()) { delete(targetDesc, null, childIds, t, softDelete); } @@ -672,10 +672,10 @@ public final class DefaultPersister implements Persister { if (!softDelete) { // ManyToMany's ... delete from intersection table BeanPropertyAssocMany[] manys = descriptor.propertiesManyToMany(); - for (int i = 0; i < manys.length; i++) { - SqlUpdate sqlDelete = manys[i].deleteByParentId(id, idList); + for (BeanPropertyAssocMany many : manys) { + SqlUpdate sqlDelete = many.deleteByParentId(id, idList); if (t.isLogSummary()) { - t.logSummary("-- Deleting intersection table entries: " + manys[i].getFullBeanName()); + t.logSummary("-- Deleting intersection table entries: " + many.getFullBeanName()); } executeSqlUpdate(sqlDelete, t); } @@ -720,8 +720,8 @@ public final class DefaultPersister implements Persister { Query q = server.createQuery(desc.getBeanType()); StringBuilder sb = new StringBuilder(30); - for (int i = 0; i < propImportDelete.length; i++) { - sb.append(propImportDelete[i].getName()).append(","); + for (BeanPropertyAssocOne aPropImportDelete : propImportDelete) { + sb.append(aPropImportDelete.getName()).append(","); } q.setAutoTune(false); q.select(sb.toString()); @@ -786,9 +786,7 @@ public final class DefaultPersister implements Persister { // exported ones with cascade save BeanPropertyAssocOne[] expOnes = desc.propertiesOneExportedSave(); - for (int i = 0; i < expOnes.length; i++) { - BeanPropertyAssocOne prop = expOnes[i]; - + for (BeanPropertyAssocOne prop : expOnes) { // check for partial beans if (request.isLoadedProperty(prop)) { EntityBean detailBean = prop.getValueAsEntityBean(parentBean); @@ -805,12 +803,12 @@ public final class DefaultPersister implements Persister { // many's with cascade save BeanPropertyAssocMany[] manys = desc.propertiesManySave(); - for (int i = 0; i < manys.length; i++) { + for (BeanPropertyAssocMany many : manys) { // check that property is loaded and collection should be cascaded to - if (request.isLoadedProperty(manys[i]) && !manys[i].isSkipSaveBeanCollection(parentBean, insertedParent)) { - saveMany(new SaveManyPropRequest(insertedParent, manys[i], parentBean, request), insertMode); + if (request.isLoadedProperty(many) && !many.isSkipSaveBeanCollection(parentBean, insertedParent)) { + saveMany(new SaveManyPropRequest(insertedParent, many, parentBean, request), insertMode); if (!insertedParent) { - request.addUpdatedManyProperty(manys[i]); + request.addUpdatedManyProperty(many); } } } @@ -891,7 +889,7 @@ public final class DefaultPersister implements Persister { private void resetModifyState() { Object details = getValue(); if (details instanceof BeanCollection) { - modifyListenReset((BeanCollection)details); + modifyListenReset((BeanCollection) details); } } } @@ -916,7 +914,7 @@ public final class DefaultPersister implements Persister { } } else { if (saveMany.isModifyListenMode()) { - // delete any removed beans via private owned. Needs to occur before + // delete any removed beans via private owned. Needs to occur before // a 'deleteMissingChildren' statement occurs removeAssocManyPrivateOwned(saveMany); } @@ -985,7 +983,7 @@ public final class DefaultPersister implements Persister { ArrayList detailIds = null; if (deleteMissingChildren) { // collect the Id's (to exclude from deleteManyDetails) - detailIds = new ArrayList(); + detailIds = new ArrayList<>(); } // increase depth for batching order @@ -1188,14 +1186,13 @@ public final class DefaultPersister implements Persister { if (expOnes.length > 0) { DeleteUnloadedForeignKeys unloaded = null; - for (int i = 0; i < expOnes.length; i++) { - BeanPropertyAssocOne prop = expOnes[i]; + for (BeanPropertyAssocOne prop : expOnes) { // for soft delete check cascade type also supports soft delete if (!softDelete || prop.getTargetDescriptor().isSoftDelete()) { if (request.isLoadedProperty(prop)) { Object detailBean = prop.getValue(parentBean); if (detailBean != null) { - deleteRecurse((EntityBean)detailBean, t, softDelete); + deleteRecurse((EntityBean) detailBean, t, softDelete); } } else { if (unloaded == null) { @@ -1213,19 +1210,19 @@ public final class DefaultPersister implements Persister { // Many's with delete cascade BeanPropertyAssocMany[] manys = desc.propertiesManyDelete(); - for (int i = 0; i < manys.length; i++) { - if (manys[i].isManyToMany()) { + for (BeanPropertyAssocMany many : manys) { + if (many.isManyToMany()) { if (!softDelete) { // delete associated rows from intersection table (but not during soft delete) - deleteAssocManyIntersection(parentBean, manys[i], t, request.isPublish()); + deleteAssocManyIntersection(parentBean, many, t, request.isPublish()); } } else { - if (ModifyListenMode.REMOVALS.equals(manys[i].getModifyListenMode())) { + if (ModifyListenMode.REMOVALS.equals(many.getModifyListenMode())) { // PrivateOwned ... // if soft delete then check target also supports soft delete - if (!softDelete || manys[i].getTargetDescriptor().isSoftDelete()) { - Object details = manys[i].getValue(parentBean); + if (!softDelete || many.getTargetDescriptor().isSoftDelete()) { + Object details = many.getValue(parentBean); if (details instanceof BeanCollection) { Set modifyRemovals = ((BeanCollection) details).getModifyRemovals(); if (modifyRemovals != null && !modifyRemovals.isEmpty()) { @@ -1233,7 +1230,7 @@ public final class DefaultPersister implements Persister { // delete the orphans that have been removed from the collection for (Object detail : modifyRemovals) { EntityBean detailBean = (EntityBean) detail; - if (manys[i].hasId(detailBean)) { + if (many.hasId(detailBean)) { deleteRecurse(detailBean, t, softDelete); } } @@ -1242,7 +1239,7 @@ public final class DefaultPersister implements Persister { } } - deleteManyDetails(t, desc, parentBean, manys[i], null, softDelete); + deleteManyDetails(t, desc, parentBean, many, null, softDelete); } } @@ -1292,7 +1289,7 @@ public final class DefaultPersister implements Persister { if (targetDesc.propertiesManyToMany().length > 0) { // convert into a list of reference objects and perform delete by object - List refList = new ArrayList(childIds.size()); + List refList = new ArrayList<>(childIds.size()); for (Object id : childIds) { refList.add(targetDesc.createReference(null, false, id, null)); } @@ -1314,16 +1311,14 @@ public final class DefaultPersister implements Persister { // imported ones with save cascade BeanPropertyAssocOne[] ones = desc.propertiesOneImportedSave(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; - + for (BeanPropertyAssocOne prop : ones) { // check for partial objects if (request.isLoadedProperty(prop)) { EntityBean detailBean = prop.getValueAsEntityBean(request.getEntityBean()); if (detailBean != null - && !prop.isSaveRecurseSkippable(detailBean) - && !prop.isReference(detailBean) - && !request.isParent(detailBean)) { + && !prop.isSaveRecurseSkippable(detailBean) + && !prop.isReference(detailBean) + && !request.isParent(detailBean)) { SpiTransaction t = request.getTransaction(); t.depth(-1); saveRecurse(detailBean, t, null, insertMode, request.isPublish()); @@ -1342,14 +1337,14 @@ public final class DefaultPersister implements Persister { DeleteUnloadedForeignKeys fkeys = null; BeanPropertyAssocOne[] ones = request.getBeanDescriptor().propertiesOneImportedDelete(); - for (int i = 0; i < ones.length; i++) { - if (!request.isLoadedProperty(ones[i])) { + for (BeanPropertyAssocOne one : ones) { + if (!request.isLoadedProperty(one)) { // we have cascade Delete on a partially populated bean and // this property was not loaded (so we are going to have to fetch it) if (fkeys == null) { fkeys = new DeleteUnloadedForeignKeys(server, request); } - fkeys.add(ones[i]); + fkeys.add(one); } } @@ -1362,8 +1357,7 @@ public final class DefaultPersister implements Persister { private void deleteAssocOne(PersistRequestBean request) { BeanPropertyAssocOne[] ones = request.getBeanDescriptor().propertiesOneImportedDelete(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; + for (BeanPropertyAssocOne prop : ones) { if (request.isLoadedProperty(prop)) { Object detailBean = prop.getValue(request.getEntityBean()); if (detailBean != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java index 9a8488231..4d2b97b50 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java @@ -23,7 +23,7 @@ import java.util.List; */ class DeleteUnloadedForeignKeys { - private final List> propList = new ArrayList>(4); + private final List> propList = new ArrayList<>(4); private final SpiEbeanServer server; @@ -59,8 +59,8 @@ class DeleteUnloadedForeignKeys { Object id = request.getBeanId(); StringBuilder sb = new StringBuilder(30); - for (int i = 0; i < propList.size(); i++) { - sb.append(propList.get(i).getName()).append(","); + for (BeanPropertyAssocOne aPropList : propList) { + sb.append(aPropList.getName()).append(","); } // run query in a separate persistence context @@ -84,8 +84,7 @@ class DeleteUnloadedForeignKeys { */ void deleteCascade() { - for (int i = 0; i < propList.size(); i++) { - BeanPropertyAssocOne prop = propList.get(i); + for (BeanPropertyAssocOne prop : propList) { Object detailBean = prop.getValue(beanWithForeignKeys); // if bean exists with a unique id then delete it diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/PstmtFactory.java b/src/main/java/com/avaje/ebeaninternal/server/persist/PstmtFactory.java index f9f995805..0cfae26b1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/PstmtFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/PstmtFactory.java @@ -38,8 +38,7 @@ public class PstmtFactory { /** * Return a prepared statement taking into account batch requirements. */ - public PreparedStatement getPstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) - throws SQLException { + public PreparedStatement getPstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) throws SQLException { BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder(); PreparedStatement stmt = batch.getStmt(sql, batchExe); @@ -63,8 +62,7 @@ public class PstmtFactory { /** * Return a callable statement taking into account batch requirements. */ - public CallableStatement getCstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) - throws SQLException { + public CallableStatement getCstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) throws SQLException { BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder(); CallableStatement stmt = (CallableStatement) batch.getStmt(sql, batchExe); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteHandler.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteHandler.java index ffd57b352..677f80112 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteHandler.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteHandler.java @@ -12,41 +12,41 @@ import java.sql.SQLException; */ public class DeleteHandler extends DmlHandler { - private final DeleteMeta meta; + private final DeleteMeta meta; - public DeleteHandler(PersistRequestBean persist, DeleteMeta meta) { - super(persist, meta.isEmptyStringAsNull()); - this.meta = meta; - } + public DeleteHandler(PersistRequestBean persist, DeleteMeta meta) { + super(persist, meta.isEmptyStringAsNull()); + this.meta = meta; + } - /** - * Generate and bind the delete statement. - */ + /** + * Generate and bind the delete statement. + */ @Override - public void bind() throws SQLException { - - sql = meta.getSql(persistRequest); - SpiTransaction t = persistRequest.getTransaction(); + public void bind() throws SQLException { - PreparedStatement pstmt; - if (persistRequest.isBatched()) { - pstmt = getPstmt(t, sql, persistRequest, false); - } else { - pstmt = getPstmt(t, sql, false); - } - dataBind = bind(pstmt); - meta.bind(persistRequest, this); - logSql(sql); - } + sql = meta.getSql(persistRequest); + SpiTransaction t = persistRequest.getTransaction(); - /** - * Execute the delete non-batch. - */ + PreparedStatement pstmt; + if (persistRequest.isBatched()) { + pstmt = getPstmt(t, sql, persistRequest, false); + } else { + pstmt = getPstmt(t, sql, false); + } + dataBind = bind(pstmt); + meta.bind(persistRequest, this); + logSql(sql); + } + + /** + * Execute the delete non-batch. + */ @Override - public int execute() throws SQLException, OptimisticLockException { - int rowCount = dataBind.executeUpdate(); - checkRowCount(rowCount); + public int execute() throws SQLException, OptimisticLockException { + int rowCount = dataBind.executeUpdate(); + checkRowCount(rowCount); return rowCount; - } - + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteMeta.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteMeta.java index 8b6684586..f09b41531 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteMeta.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteMeta.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dml; -import java.sql.SQLException; - -import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; import com.avaje.ebeaninternal.server.persist.dmlbind.BindableId; +import java.sql.SQLException; + /** * Meta data for delete handler. The meta data is for a particular bean type. It * is considered immutable and is thread safe. @@ -69,12 +69,12 @@ public final class DeleteMeta { id.dmlBind(bind, bean); switch (persist.getConcurrencyMode()) { - case VERSION: - version.dmlBind(bind, bean); - break; + case VERSION: + version.dmlBind(bind, bean); + break; - default: - break; + default: + break; } } @@ -89,14 +89,14 @@ public final class DeleteMeta { boolean publish = request.isPublish(); switch (request.determineConcurrencyMode()) { - case NONE: - return publish ? sqlNone : sqlDraftNone; + case NONE: + return publish ? sqlNone : sqlDraftNone; - case VERSION: - return publish ? sqlVersion : sqlDraftVersion; + case VERSION: + return publish ? sqlVersion : sqlDraftVersion; - default: - throw new RuntimeException("Invalid mode " + request.determineConcurrencyMode()); + default: + throw new RuntimeException("Invalid mode " + request.determineConcurrencyMode()); } } @@ -118,7 +118,7 @@ public final class DeleteMeta { } version.dmlAppend(request); } - + return request.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersister.java index 737e8000a..c37a60098 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersister.java @@ -18,77 +18,77 @@ import java.sql.SQLException; */ public final class DmlBeanPersister implements BeanPersister { - private final UpdateMeta updateMeta; + private final UpdateMeta updateMeta; - private final InsertMeta insertMeta; + private final InsertMeta insertMeta; - private final DeleteMeta deleteMeta; + private final DeleteMeta deleteMeta; - - public DmlBeanPersister(UpdateMeta updateMeta, InsertMeta insertMeta, DeleteMeta deleteMeta) { - this.updateMeta = updateMeta; - this.insertMeta = insertMeta; - this.deleteMeta = deleteMeta; - } + public DmlBeanPersister(UpdateMeta updateMeta, InsertMeta insertMeta, DeleteMeta deleteMeta) { - /** - * execute the bean delete request. - */ - public int delete(PersistRequestBean request) { + this.updateMeta = updateMeta; + this.insertMeta = insertMeta; + this.deleteMeta = deleteMeta; + } - DeleteHandler delete = new DeleteHandler(request, deleteMeta); - return execute(request, delete); - } + /** + * execute the bean delete request. + */ + public int delete(PersistRequestBean request) { - /** - * execute the bean insert request. - */ - public void insert(PersistRequestBean request) { + DeleteHandler delete = new DeleteHandler(request, deleteMeta); + return execute(request, delete); + } - InsertHandler insert = new InsertHandler(request, insertMeta); - execute(request, insert); - } + /** + * execute the bean insert request. + */ + public void insert(PersistRequestBean request) { - /** - * execute the bean update request. - */ - public void update(PersistRequestBean request) { + InsertHandler insert = new InsertHandler(request, insertMeta); + execute(request, insert); + } - UpdateHandler update = new UpdateHandler(request, updateMeta); - execute(request, update); - } + /** + * execute the bean update request. + */ + public void update(PersistRequestBean request) { - /** - * execute request taking batching into account. - */ - private int execute(PersistRequestBean request, PersistHandler handler) { + UpdateHandler update = new UpdateHandler(request, updateMeta); + execute(request, update); + } + + /** + * execute request taking batching into account. + */ + private int execute(PersistRequestBean request, PersistHandler handler) { boolean batched = request.isBatched(); - try { - handler.bind(); - if (batched) { - handler.addBatch(); + try { + handler.bind(); + if (batched) { + handler.addBatch(); return -1; - } else { - return handler.execute(); - } + } else { + return handler.execute(); + } - } catch (SQLException e) { + } catch (SQLException e) { // log the error to the transaction log - String errMsg = StringHelper.replaceStringMulti(e.getMessage(), new String[]{"\r","\n"}, "\\n "); - String msg = "ERROR executing DML bindLog["+handler.getBindLog()+"] error["+errMsg+"]"; + String errMsg = StringHelper.replaceStringMulti(e.getMessage(), new String[]{"\r", "\n"}, "\\n "); + String msg = "ERROR executing DML bindLog[" + handler.getBindLog() + "] error[" + errMsg + "]"; if (request.getTransaction().isLogSummary()) { request.getTransaction().logSummary(msg); } - throw new PersistenceException(msg, e); + throw new PersistenceException(msg, e); - } finally { - if (!batched && handler != null) { + } finally { + if (!batched && handler != null) { handler.close(); - } - } - } + } + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java index 5bfcf5957..d4b9fcebd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java @@ -9,25 +9,25 @@ import com.avaje.ebeaninternal.server.persist.BeanPersisterFactory; * Factory for creating a DmlBeanPersister for a bean type. */ public class DmlBeanPersisterFactory implements BeanPersisterFactory { - - private final MetaFactory metaFactory; - - public DmlBeanPersisterFactory(DatabasePlatform dbPlatform) { - this.metaFactory = new MetaFactory(dbPlatform); - } - - - /** - * Create a DmlBeanPersister for the given bean type. - */ - public BeanPersister create(BeanDescriptor desc) { - - UpdateMeta updMeta = metaFactory.createUpdate(desc); - DeleteMeta delMeta = metaFactory.createDelete(desc); - InsertMeta insMeta = metaFactory.createInsert(desc); - - return new DmlBeanPersister(updMeta, insMeta, delMeta); - - } - + + private final MetaFactory metaFactory; + + public DmlBeanPersisterFactory(DatabasePlatform dbPlatform) { + this.metaFactory = new MetaFactory(dbPlatform); + } + + + /** + * Create a DmlBeanPersister for the given bean type. + */ + public BeanPersister create(BeanDescriptor desc) { + + UpdateMeta updMeta = metaFactory.createUpdate(desc); + DeleteMeta delMeta = metaFactory.createDelete(desc); + InsertMeta insMeta = metaFactory.createInsert(desc); + + return new DmlBeanPersister(updMeta, insMeta, delMeta); + + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlHandler.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlHandler.java index f49c35936..98721b20d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlHandler.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlHandler.java @@ -254,13 +254,13 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest { * Check with useGeneratedKeys to get appropriate PreparedStatement. */ protected PreparedStatement getPstmt(SpiTransaction t, String sql, boolean genKeys) throws SQLException { - + Connection conn = t.getInternalConnection(); if (genKeys) { // the Id generated is always the first column // Required to stop Oracle10 giving us Oracle rowId?? // Other jdbc drivers seem fine without this hint. - int[] columns = { 1 }; + int[] columns = {1}; return conn.prepareStatement(sql, columns); } else { @@ -272,7 +272,7 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest { * Return a prepared statement taking into account batch requirements. */ protected PreparedStatement getPstmt(SpiTransaction t, String sql, PersistRequestBean request, - boolean genKeys) throws SQLException { + boolean genKeys) throws SQLException { BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder(); PreparedStatement stmt = batch.getStmt(sql, request); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlMode.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlMode.java index 797bfcf01..c29af82e9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlMode.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlMode.java @@ -5,14 +5,14 @@ package com.avaje.ebeaninternal.server.persist.dml; */ public enum DmlMode { - /** - * The Insert SET. - */ - INSERT, - - /** - * The Update SET. - */ - UPDATE, - + /** + * The Insert SET. + */ + INSERT, + + /** + * The Update SET. + */ + UPDATE, + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/MetaFactory.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/MetaFactory.java index 1ad53e203..374500421 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/MetaFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/MetaFactory.java @@ -56,7 +56,7 @@ public class MetaFactory { */ public UpdateMeta createUpdate(BeanDescriptor desc) { - List setList = new ArrayList(); + List setList = new ArrayList<>(); baseFact.create(setList, desc, DmlMode.UPDATE, includeLobs); embeddedFact.create(setList, desc, DmlMode.UPDATE, includeLobs); @@ -90,7 +90,7 @@ public class MetaFactory { BindableId id = idFact.createId(desc); - List allList = new ArrayList(); + List allList = new ArrayList<>(); baseFact.create(allList, desc, DmlMode.INSERT, includeLobs); embeddedFact.create(allList, desc, DmlMode.INSERT, includeLobs); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java index 073e23d71..2d5680599 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java @@ -1,7 +1,7 @@ package com.avaje.ebeaninternal.server.persist.dml; -import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebeaninternal.api.SpiUpdatePlan; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; @@ -116,7 +116,7 @@ public final class UpdateMeta { // build a new UpdatePlan and cache it // build a bindableList that only contains the changed properties - List list = new ArrayList(); + List list = new ArrayList<>(); set.addToUpdate(persistRequest, list); BindableList bindableList = new BindableList(list); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdatePlan.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdatePlan.java index 596a4a5e7..012548a7e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdatePlan.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdatePlan.java @@ -1,7 +1,7 @@ package com.avaje.ebeaninternal.server.persist.dml; -import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebeaninternal.api.SpiUpdatePlan; import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/package.html b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/package.html index 05ba5dce1..7a60e6148 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/package.html @@ -1,10 +1,10 @@ - - Bean DML persistence implementation + + Bean DML persistence implementation Bean DML persistence implementation - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java index 797b31609..a3d877203 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.List; + /** * Item held by Meta objects used to generate and bind bean insert update and * delete statements. diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java index ebfb52d5c..f40d6275e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanPropertyCompound; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; + /** * Bindable for a Immutable Compound value object. */ @@ -34,8 +34,8 @@ public class BindableCompound implements Bindable { public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (BindableProperty item : items) { + item.dmlAppend(request); } } @@ -51,8 +51,8 @@ public class BindableCompound implements Bindable { Object valueObject = compound.getValue(bean); // bind each of the underlying scalar values for this compound type - for (int i = 0; i < items.length; i++) { - items[i].dmlBindObject(bindRequest, valueObject); + for (BindableProperty item : items) { + item.dmlBindObject(bindRequest, valueObject); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java index 21235b5f9..881875ff6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java @@ -1,15 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.InheritInfo; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for inserting a discriminator value. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java index 29d5b9e70..9461ab30c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; + /** * Bindable for a Embedded bean. */ @@ -34,8 +34,8 @@ public class BindableEmbedded implements Bindable { public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (Bindable item : items) { + item.dmlAppend(request); } } @@ -50,14 +50,14 @@ public class BindableEmbedded implements Bindable { // get the embedded bean EntityBean embBean = (EntityBean) embProp.getValue(bean); if (embBean == null) { - for (int i = 0; i < items.length; i++) { - items[i].dmlBind(bindRequest, null); + for (Bindable item : items) { + item.dmlBind(bindRequest, null); } } else { //EntityBeanIntercept ebi = embBean._ebean_getIntercept(); - for (int i = 0; i < items.length; i++) { + for (Bindable item : items) { //if (ebi.isLoadedProperty(props[i].getPropertyIndex())) { - items[i].dmlBind(bindRequest, embBean); + item.dmlBind(bindRequest, embBean); //} } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java index 4863f7e51..03ffe0392 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.sql.Types; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.sql.Types; +import java.util.List; + /** * Bindable for a DB encrypted BeanProperty. */ @@ -48,8 +48,7 @@ public class BindableEncryptedProperty implements Bindable { /** * Bind a value in a Insert SET clause. */ - public void dmlBind(BindableRequest request, EntityBean bean) - throws SQLException { + public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException { Object value = null; if (bean != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java index b07be39d2..e0bd48f6c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java @@ -1,11 +1,5 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; @@ -13,6 +7,11 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; + /** * Bindable for a EmbeddedId. */ @@ -64,18 +63,18 @@ public final class BindableIdEmbedded implements BindableId { EntityBean idValue = (EntityBean) embId.getValue(bean); - for (int i = 0; i < props.length; i++) { + for (BeanProperty prop : props) { - Object value = props[i].getValue(idValue); - request.bind(value, props[i]); + Object value = prop.getValue(idValue); + request.bind(value, prop); } request.setIdValue(idValue); } public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < props.length; i++) { - request.appendColumn(props[i].getDbColumn()); + for (BeanProperty prop : props) { + request.appendColumn(prop.getDbColumn()); } } @@ -83,8 +82,8 @@ public final class BindableIdEmbedded implements BindableId { if (matches == null) { String m = "Matches for the concatenated key columns where not found?" - + " I expect that the concatenated key was null, and this bean does" - + " not have ManyToOne assoc beans matching the primary key columns?"; + + " I expect that the concatenated key was null, and this bean does" + + " not have ManyToOne assoc beans matching the primary key columns?"; throw new PersistenceException(m); } @@ -94,8 +93,8 @@ public final class BindableIdEmbedded implements BindableId { EntityBean newId = (EntityBean) embId.createEmbeddedId(); // populate it from the assoc one id values... - for (int i = 0; i < matches.length; i++) { - matches[i].populate(bean, newId); + for (MatchedImportedProperty matche : matches) { + matche.populate(bean, newId); } // support PropertyChangeSupport diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java index 3c2584a70..357b5bbb9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.List; + public class BindableIdEmpty implements BindableId { public boolean isEmpty() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java index 2cba8c20a..1db027f63 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java @@ -1,15 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for a single scalar id property. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java index cf46cd141..2843c8684 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java @@ -1,13 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * List of Bindable items. */ @@ -23,7 +24,7 @@ public class BindableList implements Bindable { * Return a bindable list that excludes @DraftOnly properties. */ public BindableList excludeDraftOnly() { - List copy = new ArrayList(items.length); + List copy = new ArrayList<>(items.length); for (Bindable b : items) { if (!b.isDraftOnly()) { copy.add(b); @@ -38,29 +39,24 @@ public class BindableList implements Bindable { } public void addAll(List list) { - for (int i = 0; i < items.length; i++) { - list.add(items[i]); - } + Collections.addAll(list, items); } public void addToUpdate(PersistRequestBean request, List list) { - for (int i = 0; i < items.length; i++) { - items[i].addToUpdate(request, list); + for (Bindable item : items) { + item.addToUpdate(request, list); } } public void dmlAppend(GenerateDmlRequest request) { - - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (Bindable item : items) { + item.dmlAppend(request); } } - public void dmlBind(BindableRequest bindRequest, EntityBean bean) - throws SQLException { - - for (int i = 0; i < items.length; i++) { - items[i].dmlBind(bindRequest, bean); + public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException { + for (Bindable item : items) { + item.dmlBind(bindRequest, bean); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableProperty.java index 5b3b85d1b..d5286035d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableProperty.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for a single BeanProperty. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java index c7b6e8016..f036e3031 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; + /** * Bindable for insert on a property with a GeneratedProperty. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java index 5d28a68af..68331e690 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for update on a property with a GeneratedProperty. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java index c980c9be6..cd87ec737 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java @@ -1,10 +1,5 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; @@ -12,6 +7,10 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.deploy.id.ImportedId; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for a unidirectional relationship. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java index 20e21c1e1..58c8a57ba 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.util.List; - import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.persist.dml.DmlMode; +import java.util.List; + /** * A factory that builds Bindable for BeanPropertyAssocOne properties. */ @@ -21,21 +21,21 @@ public class FactoryAssocOnes { BeanPropertyAssocOne[] ones = desc.propertiesOneImported(); - for (int i = 0; i < ones.length; i++) { - if (!ones[i].isImportedPrimaryKey()) { + for (BeanPropertyAssocOne one : ones) { + if (!one.isImportedPrimaryKey()) { switch (mode) { case INSERT: - if (!ones[i].isInsertable()) { + if (!one.isInsertable()) { continue; } break; case UPDATE: - if (!ones[i].isUpdateable()) { + if (!one.isUpdateable()) { continue; } break; } - list.add(new BindableAssocOne(ones[i])); + list.add(new BindableAssocOne(one)); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java index 9ce0717fb..e0c75fdac 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.BeanPropertyCompound; import com.avaje.ebeaninternal.server.persist.dml.DmlMode; +import java.util.ArrayList; +import java.util.List; + /** * Add base properties to the BindableList for a bean type. *

@@ -31,13 +31,13 @@ public class FactoryBaseProperties { add(desc.propertiesBaseScalar(), list, mode, withLobs); BeanPropertyCompound[] compoundProps = desc.propertiesBaseCompound(); - for (int i = 0; i < compoundProps.length; i++) { - BeanProperty[] props = compoundProps[i].getScalarProperties(); + for (BeanPropertyCompound compoundProp : compoundProps) { + BeanProperty[] props = compoundProp.getScalarProperties(); - List newList = new ArrayList(props.length); + List newList = new ArrayList<>(props.length); addCompound(props, newList, mode, withLobs); - BindableCompound compoundBindable = new BindableCompound(compoundProps[i], newList); + BindableCompound compoundBindable = new BindableCompound(compoundProp, newList); list.add(compoundBindable); } @@ -45,8 +45,8 @@ public class FactoryBaseProperties { private void add(BeanProperty[] props, List list, DmlMode mode, boolean withLobs) { - for (int i = 0; i < props.length; i++) { - Bindable item = factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + Bindable item = factoryProperty.create(prop, mode, withLobs); if (item != null) { list.add(item); } @@ -55,8 +55,8 @@ public class FactoryBaseProperties { private void addCompound(BeanProperty[] props, List list, DmlMode mode, boolean withLobs) { - for (int i = 0; i < props.length; i++) { - BindableProperty item = (BindableProperty) factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + BindableProperty item = (BindableProperty) factoryProperty.create(prop, mode, withLobs); if (item != null) { list.add(item); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java index 7cedbbaa2..709c5524c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.persist.dml.DmlMode; +import java.util.ArrayList; +import java.util.List; + /** * A factory that builds Bindable for embedded bean properties. */ @@ -26,20 +26,20 @@ public class FactoryEmbedded { BeanPropertyAssocOne[] embedded = desc.propertiesEmbedded(); - for (int j = 0; j < embedded.length; j++) { + for (BeanPropertyAssocOne anEmbedded : embedded) { - BeanProperty[] props = embedded[j].getProperties(); + BeanProperty[] props = anEmbedded.getProperties(); - List bindList = new ArrayList(props.length); + List bindList = new ArrayList<>(props.length); - for (int i = 0; i < props.length; i++) { - Bindable item = factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + Bindable item = factoryProperty.create(prop, mode, withLobs); if (item != null) { bindList.add(item); } } - list.add(new BindableEmbedded(embedded[j], bindList)); + list.add(new BindableEmbedded(anEmbedded, bindList)); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java index 9e4da8a12..a95505f2c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java @@ -66,14 +66,14 @@ class MatchedImportedProperty { String dbColumn = prop.getDbColumn(); BeanPropertyAssocOne[] assocOnes = desc.propertiesOne(); - for (int i = 0; i < assocOnes.length; i++) { - if (assocOnes[i].isImportedPrimaryKey()) { + for (BeanPropertyAssocOne assocOne1 : assocOnes) { + if (assocOne1.isImportedPrimaryKey()) { // search using the ImportedId from the assoc one - BeanProperty foreignMatch = assocOnes[i].getImportedId().findMatchImport(dbColumn); + BeanProperty foreignMatch = assocOne1.getImportedId().findMatchImport(dbColumn); if (foreignMatch != null) { - return new MatchedImportedProperty(assocOnes[i], foreignMatch, prop); + return new MatchedImportedProperty(assocOne1, foreignMatch, prop); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/package.html b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/package.html index 829152eca..e2b530d0f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/package.html @@ -1,10 +1,10 @@ - - Bindable objects to support Bean DML + + Bindable objects to support Bean DML Bindable objects to support Bean DML - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/package.html b/src/main/java/com/avaje/ebeaninternal/server/persist/package.html index 5faa44c3e..589539fc1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/package.html @@ -1,15 +1,15 @@ - - Persistence Implementation + + Persistence Implementation Persistence Implementation

-Implementing the saving and deleting of beans, and the executing of -updateable and callable sql. + Implementing the saving and deleting of beans, and the executing of + updateable and callable sql.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java index 39c78781d..62c23aa7c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java @@ -10,21 +10,21 @@ import java.util.Map; */ public class BeanPropertiesReader { - private final Map propertyIndexMap = new HashMap(); - + private final Map propertyIndexMap = new HashMap<>(); + private final String[] props; - + public BeanPropertiesReader(Class clazz) { this.props = getProperties(clazz); - for (int i=0; i clazz) { try { Field field = clazz.getField("_ebean_props"); return (String[]) field.get(null); } catch (Exception e) { - throw new IllegalStateException("Error getting _ebean_props field on type "+clazz, e); + throw new IllegalStateException("Error getting _ebean_props field on type " + clazz, e); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyGetter.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyGetter.java index 652735249..65687da8b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyGetter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyGetter.java @@ -7,11 +7,11 @@ import com.avaje.ebean.bean.EntityBean; */ public interface BeanPropertyGetter { - /** - * Return the value of a given bean property. - */ - Object get(EntityBean bean); + /** + * Return the value of a given bean property. + */ + Object get(EntityBean bean); - Object getIntercept(EntityBean bean); + Object getIntercept(EntityBean bean); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfo.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfo.java index ebe1764c1..d40a4f607 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfo.java @@ -9,18 +9,18 @@ package com.avaje.ebeaninternal.server.properties; */ public interface BeanPropertyInfo { - /** - * Create an EntityBean for this type. - */ - Object createEntityBean(); - - /** - * Return the getter for a given bean property. - */ - BeanPropertyGetter getGetter(int position); - - /** - * Return the setter for a given bean property. - */ - BeanPropertySetter getSetter(int position); + /** + * Create an EntityBean for this type. + */ + Object createEntityBean(); + + /** + * Return the getter for a given bean property. + */ + BeanPropertyGetter getGetter(int position); + + /** + * Return the setter for a given bean property. + */ + BeanPropertySetter getSetter(int position); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfoFactory.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfoFactory.java index 5b2befa02..1f5e550e3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfoFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfoFactory.java @@ -7,8 +7,8 @@ package com.avaje.ebeaninternal.server.properties; */ public interface BeanPropertyInfoFactory { - /** - * Create the BeanReflect for the given plain bean and its EntityBean equivalent. - */ - BeanPropertyInfo create(Class entityBeanType); + /** + * Create the BeanReflect for the given plain bean and its EntityBean equivalent. + */ + BeanPropertyInfo create(Class entityBeanType); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertySetter.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertySetter.java index c66a4cc0c..a3e31b331 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertySetter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertySetter.java @@ -7,17 +7,17 @@ import com.avaje.ebean.bean.EntityBean; */ public interface BeanPropertySetter { - /** - * Set the property value of a bean. - */ - void set(EntityBean bean, Object value); + /** + * Set the property value of a bean. + */ + void set(EntityBean bean, Object value); - /** - * Set the property value of a bean with interception checks. - *

- * This could invoke lazy loading and or oldValues creation. - *

- */ - void setIntercept(EntityBean bean, Object value); + /** + * Set the property value of a bean with interception checks. + *

+ * This could invoke lazy loading and or oldValues creation. + *

+ */ + void setIntercept(EntityBean bean, Object value); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfo.java b/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfo.java index 69429e449..0ff037f1c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfo.java @@ -1,11 +1,10 @@ package com.avaje.ebeaninternal.server.properties; -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; +import com.avaje.ebean.bean.EntityBean; import javax.persistence.PersistenceException; - -import com.avaje.ebean.bean.EntityBean; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; /** * A BeanReflect implementation based on the enhancement that creates EntityBean @@ -20,11 +19,10 @@ public final class EnhanceBeanPropertyInfo implements BeanPropertyInfo { public EnhanceBeanPropertyInfo(Class clazz) { try { if (Modifier.isAbstract(clazz.getModifiers())) { - this.constructor = null; + this.constructor = null; } else { this.constructor = defaultConstructor(clazz); } - } catch (Exception e) { throw new PersistenceException(e); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfoFactory.java b/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfoFactory.java index d70911890..fe8fa1fec 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfoFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfoFactory.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.properties; /** - * Creates a BeanReflectFactory based on the enhancement that + * Creates a BeanReflectFactory based on the enhancement that * creates EntityBean implementations. */ public final class EnhanceBeanPropertyInfoFactory implements BeanPropertyInfoFactory { - public BeanPropertyInfo create(Class entityBeanType) { - return new EnhanceBeanPropertyInfo(entityBeanType); - } + public BeanPropertyInfo create(Class entityBeanType) { + return new EnhanceBeanPropertyInfo(entityBeanType); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/package.html b/src/main/java/com/avaje/ebeaninternal/server/properties/package.html index 4c4321727..a0f5dda50 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/package.html @@ -1,15 +1,15 @@ - - Bean Reflection + + Bean Reflection Bean reflection Implementation

-Abstracts the bean property getter and setter methods. -Allows Code generation or reflection to be used. + Abstracts the bean property getter and setter methods. + Allows Code generation or reflection to be used.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/BaseFuture.java b/src/main/java/com/avaje/ebeaninternal/server/query/BaseFuture.java index 05fdfc337..e00a98f78 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/BaseFuture.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/BaseFuture.java @@ -12,11 +12,11 @@ import java.util.concurrent.TimeoutException; * @param the entity bean type * @author rbygrave */ -public abstract class BaseFuture implements Future { +abstract class BaseFuture implements Future { - protected final FutureTask futureTask; + final FutureTask futureTask; - public BaseFuture(FutureTask futureTask) { + BaseFuture(FutureTask futureTask) { this.futureTask = futureTask; } @@ -28,9 +28,7 @@ public abstract class BaseFuture implements Future { return futureTask.get(); } - public T get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return futureTask.get(timeout, unit); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java index 7fd6a16a1..8a6663b36 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java @@ -209,7 +209,7 @@ public class CQuery implements DbReadContext, CancelableQuery { this.objectGraphNode = query.getParentNode(); this.profilingListener = query.getProfilingListener(); this.autoTuneProfiling = profilingListener != null; - this.profilingListenerRef = autoTuneProfiling ? new WeakReference(profilingListener) : null; + this.profilingListenerRef = autoTuneProfiling ? new WeakReference<>(profilingListener) : null; // set the generated sql back to the query // so its available to the user... @@ -276,7 +276,7 @@ public class CQuery implements DbReadContext, CancelableQuery { return predicates; } - public SpiOrmQueryRequest getQueryRequest() { + SpiOrmQueryRequest getQueryRequest() { return request; } @@ -297,14 +297,14 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Prepare bind and execute query with Forward only hints. */ - public boolean prepareBindExecuteQueryForwardOnly(boolean dbPlatformForwardOnlyHint) throws SQLException { + boolean prepareBindExecuteQueryForwardOnly(boolean dbPlatformForwardOnlyHint) throws SQLException { return prepareBindExecuteQueryWithOption(dbPlatformForwardOnlyHint); } /** * Prepare bind and execute the query normally. */ - public boolean prepareBindExecuteQuery() throws SQLException { + boolean prepareBindExecuteQuery() throws SQLException { return prepareBindExecuteQueryWithOption(false); } @@ -494,11 +494,11 @@ public class CQuery implements DbReadContext, CancelableQuery { return true; } - public long getQueryExecutionTimeMicros() { + long getQueryExecutionTimeMicros() { return executionTimeMicros; } - public boolean readBean() throws SQLException { + boolean readBean() throws SQLException { boolean result = hasNext(); updateExecutionStatistics(); @@ -531,9 +531,9 @@ public class CQuery implements DbReadContext, CancelableQuery { * Read version beans and their effective dates. */ @SuppressWarnings("unchecked") - public List> readVersions() throws SQLException { + List> readVersions() throws SQLException { - List> versionList = new ArrayList>(); + List> versionList = new ArrayList<>(); Version version; while ((version = readNextVersion()) != null) { @@ -552,7 +552,7 @@ public class CQuery implements DbReadContext, CancelableQuery { return null; } - public BeanCollection readCollection() throws SQLException { + BeanCollection readCollection() throws SQLException { while (hasNext()) { EntityBean bean = next(); @@ -563,7 +563,7 @@ public class CQuery implements DbReadContext, CancelableQuery { return collection; } - protected void updateExecutionStatistics() { + void updateExecutionStatistics() { try { long exeNano = System.nanoTime() - startNano; executionTimeMicros = TimeUnit.NANOSECONDS.toMicros(exeNano); @@ -578,17 +578,17 @@ public class CQuery implements DbReadContext, CancelableQuery { } } - public QueryIterator readIterate(int bufferSize, OrmQueryRequest request) { + QueryIterator readIterate(int bufferSize, OrmQueryRequest request) { if (bufferSize > 0) { - return new CQueryIteratorWithBuffer(this, request, bufferSize); + return new CQueryIteratorWithBuffer<>(this, request, bufferSize); } else { - return new CQueryIteratorSimple(this, request); + return new CQueryIteratorSimple<>(this, request); } } - public String getLoadedRowDetail() { + String getLoadedRowDetail() { if (manyProperty == null) { return String.valueOf(rowCount); } else { @@ -618,7 +618,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Return the where predicate for display in the transaction log. */ - public String getLogWhereSql() { + String getLogWhereSql() { return logWhereSql; } @@ -641,7 +641,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Return the short bean name. */ - public String getBeanName() { + String getBeanName() { return desc.getName(); } @@ -655,7 +655,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Create a PersistenceException including interesting information like the bindLog and sql used. */ - public PersistenceException createPersistenceException(SQLException e) { + PersistenceException createPersistenceException(SQLException e) { return createPersistenceException(e, getTransaction(), bindLog, sql); } @@ -663,7 +663,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Create a PersistenceException including interesting information like the bindLog and sql used. */ - public static PersistenceException createPersistenceException(SQLException e, SpiTransaction t, String bindLog, String sql) { + static PersistenceException createPersistenceException(SQLException e, SpiTransaction t, String bindLog, String sql) { if (t.isLogSummary()) { // log the error to the transaction log @@ -723,7 +723,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * A find bean query with read auditing so build and log the ReadEvent. */ - public void auditFind(EntityBean bean) { + void auditFind(EntityBean bean) { if (bean != null) { // only audit when a bean was actually found desc.readAuditBean(queryPlan.getAuditQueryKey(), bindLog, bean); @@ -733,11 +733,11 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * a find many query with read auditing so build the ReadEvent and log it. */ - public void auditFindMany() { + void auditFindMany() { if (!collection.isEmpty()) { // get the id values of the underlying collection - List ids = new ArrayList(collection.size()); + List ids = new ArrayList<>(collection.size()); Collection underlyingBeans = collection.getActualDetails(); for (T underlyingBean : underlyingBeans) { ids.add(desc.getIdForJson(underlyingBean)); @@ -760,7 +760,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Indicate that read auditing is occurring on a this findIterate query. */ - public void auditFindIterate() { + void auditFindIterate() { auditFindIterate = true; } @@ -779,7 +779,7 @@ public class CQuery implements DbReadContext, CancelableQuery { private void auditIterateNextBean() { if (auditFindIterateIds == null) { - auditFindIterateIds = new ArrayList(100); + auditFindIterateIds = new ArrayList<>(100); } auditFindIterateIds.add(desc.getIdForJson(nextBean)); if (auditFindIterateIds.size() >= 100) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java index 4121f8dee..39ac47505 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java @@ -31,7 +31,7 @@ import java.util.List; * Generates the SQL SELECT statements taking into account the physical * deployment properties. */ -public class CQueryBuilder { +class CQueryBuilder { private final String tableAliasPlaceHolder; private final String columnAliasPrefix; @@ -53,7 +53,7 @@ public class CQueryBuilder { /** * Create the SqlGenSelect. */ - public CQueryBuilder(DatabasePlatform dbPlatform, Binder binder, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { + CQueryBuilder(DatabasePlatform dbPlatform, Binder binder, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { this.dbPlatform = dbPlatform; this.binder = binder; @@ -70,7 +70,7 @@ public class CQueryBuilder { * split the order by claus on the field delimiter and prefix each field with * the relation name */ - public static String prefixOrderByFields(String name, String orderBy) { + static String prefixOrderByFields(String name, String orderBy) { StringBuilder sb = new StringBuilder(); for (String token : orderBy.split(",")) { if (sb.length() > 0) { @@ -88,7 +88,7 @@ public class CQueryBuilder { /** * Build the delete query. */ - public CQueryUpdate buildUpdateQuery(String type, OrmQueryRequest request) { + CQueryUpdate buildUpdateQuery(String type, OrmQueryRequest request) { SpiQuery query = request.getQuery(); String rootTableAlias = query.getAlias(); @@ -165,7 +165,7 @@ public class CQueryBuilder { return StringHelper.replaceString(sql, "${RTA}", replaceWith); } - public CQueryFetchSingleAttribute buildFetchAttributeQuery(OrmQueryRequest request) { + CQueryFetchSingleAttribute buildFetchAttributeQuery(OrmQueryRequest request) { SpiQuery query = request.getQuery(); query.setSingleAttribute(); @@ -191,7 +191,7 @@ public class CQueryBuilder { /** * Build the find ids query. */ - public CQueryFetchSingleAttribute buildFetchIdsQuery(OrmQueryRequest request) { + CQueryFetchSingleAttribute buildFetchIdsQuery(OrmQueryRequest request) { request.getQuery().setSelectId(); return buildFetchAttributeQuery(request); @@ -214,7 +214,7 @@ public class CQueryBuilder { /** * Build the row count query. */ - public CQueryRowCount buildRowCountQuery(OrmQueryRequest request) { + CQueryRowCount buildRowCountQuery(OrmQueryRequest request) { SpiQuery query = request.getQuery(); @@ -275,7 +275,7 @@ public class CQueryBuilder { * Return the SQL Select statement as a String. Converts logical property * names to physical deployment column names. */ - public CQuery buildQuery(OrmQueryRequest request) { + CQuery buildQuery(OrmQueryRequest request) { CQueryPredicates predicates = new CQueryPredicates(binder, request); @@ -284,7 +284,7 @@ public class CQueryBuilder { // Reuse the query plan so skip generating SqlTree and SQL. // We do prepare and bind the new parameters predicates.prepare(false); - return new CQuery(request, predicates, queryPlan); + return new CQuery<>(request, predicates, queryPlan); } // RawSql or Generated Sql query @@ -327,7 +327,7 @@ public class CQueryBuilder { // gather query performance statistics based on it. request.putQueryPlan(queryPlan); - return new CQuery(request, predicates, queryPlan); + return new CQuery<>(request, predicates, queryPlan); } /** @@ -363,8 +363,15 @@ public class CQueryBuilder { RawSql.ColumnMapping.Column column = it.next(); String propertyName = column.getPropertyName(); if (!RawSqlBuilder.IGNORE_COLUMN.equals(propertyName)) { - ElPropertyValue el = descriptor.getElGetValue(propertyName); + if (el == null && propertyName.endsWith("Id")) { + // try default naming convention for foreign key columns + String foreignIdPath = assocOneIdPath(propertyName); + el = descriptor.getElGetValue(foreignIdPath); + if (el != null) { + propertyName = foreignIdPath; + } + } if (el == null) { throw new PersistenceException("Property [" + propertyName + "] not found on " + descriptor.getFullName()); } else { @@ -404,6 +411,13 @@ public class CQueryBuilder { return new SqlTreeBuilder(request, predicates, detail, rawNoId).build(); } + /** + * Return a path for a foreign key property using the default naming convention. + */ + private String assocOneIdPath(String propertyName) { + return propertyName.substring(0, propertyName.length() - 2) + ".id"; + } + /** * Return the SQL response with row limiting (when not an update statement). */ @@ -482,7 +496,7 @@ public class CQueryBuilder { String idSql = desc.getIdBinderIdSql(); if (idSql.isEmpty()) { throw new IllegalStateException("Executing FindById query on entity bean " + desc.getName() - + " that doesn't have an @Id property??"); + + " that doesn't have an @Id property??"); } if (stripAlias) { // strip the table alias for use in update statement diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilderRawSql.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilderRawSql.java index 296f53f83..c342731c3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilderRawSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilderRawSql.java @@ -11,7 +11,7 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.querydefn.OrmQueryLimitRequest; import com.avaje.ebeaninternal.server.util.BindParamsParser; -public class CQueryBuilderRawSql { +class CQueryBuilderRawSql { private final SqlLimiter sqlLimiter; private final DatabasePlatform dbPlatform; @@ -24,7 +24,7 @@ public class CQueryBuilderRawSql { /** * Build the full SQL Select statement for the request. */ - public SqlLimitResponse buildSql(OrmQueryRequest request, CQueryPredicates predicates, RawSql.Sql rsql) { + SqlLimitResponse buildSql(OrmQueryRequest request, CQueryPredicates predicates, RawSql.Sql rsql) { if (rsql == null) { // this is a ResultSet based RawSql query - just use some placeholder for the SQL diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java index 50c6e62fd..ef84db1db 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java @@ -5,24 +5,24 @@ import java.util.Map; /** * Support 'asDraft' queries. */ -public class CQueryDraftSupport { +class CQueryDraftSupport { /** * The mapping of base tables to their matching 'draft' table. */ private final Map tableMap; - public CQueryDraftSupport(Map tableMap) { + CQueryDraftSupport(Map tableMap) { this.tableMap = tableMap; } /** * Return the draft table associated to the base table. - * + *

* This returns null for entities that are not draftable and in that case * the usual base table is used. */ - public String getDraftTable(String table) { + String getDraftTable(String table) { return tableMap.get(table); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java index 49d8625f9..3c95a3850 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java @@ -1,5 +1,6 @@ package com.avaje.ebeaninternal.server.query; +import com.avaje.ebean.QueryIterator; import com.avaje.ebean.ValuePair; import com.avaje.ebean.Version; import com.avaje.ebean.bean.BeanCollection; @@ -10,7 +11,6 @@ import com.avaje.ebean.config.dbplatform.DatabasePlatform; import com.avaje.ebeaninternal.api.SpiQuery; import com.avaje.ebeaninternal.server.core.DiffHelp; import com.avaje.ebeaninternal.server.core.OrmQueryRequest; -import com.avaje.ebean.QueryIterator; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.lib.util.Str; import com.avaje.ebeaninternal.server.persist.Binder; @@ -99,7 +99,7 @@ public class CQueryEngine { @SuppressWarnings("unchecked") private List findAttributeList(OrmQueryRequest request, CQueryFetchSingleAttribute rcQuery) { try { - List list = (List)rcQuery.findList(); + List list = (List) rcQuery.findList(); if (request.isLogSql()) { logGeneratedSql(request, rcQuery.getGeneratedSql(), rcQuery.getBindLog()); } @@ -275,7 +275,7 @@ public class CQueryEngine { } } // put an empty map into the last one - current.setDiff(new LinkedHashMap()); + current.setDiff(new LinkedHashMap<>()); } } @@ -299,8 +299,7 @@ public class CQueryEngine { /** * Find a list/map/set of beans. */ - public BeanCollection findMany(OrmQueryRequest request) { - + BeanCollection findMany(OrmQueryRequest request) { SpiQuery query = request.getQuery(); if (!query.isDistinct() && (query.getMaxRows() > 1 || query.getFirstRow() > 0)) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java index 431d84edd..997b5c12b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java @@ -59,7 +59,7 @@ class CQueryFetchSingleAttribute { /** * Create the Sql select based on the request. */ - public CQueryFetchSingleAttribute(OrmQueryRequest request, CQueryPredicates predicates, CQueryPlan plan) { + CQueryFetchSingleAttribute(OrmQueryRequest request, CQueryPredicates predicates, CQueryPlan plan) { this.request = request; this.query = request.getQuery(); this.sql = plan.getSql(); @@ -76,10 +76,10 @@ class CQueryFetchSingleAttribute { protected String getSummary() { StringBuilder sb = new StringBuilder(80); sb.append("FindAttr exeMicros[").append(executionTimeMicros) - .append("] rows[").append(rowCount) - .append("] type[").append(desc.getName()) - .append("] predicates[").append(predicates.getLogWhereSql()) - .append("] bind[").append(bindLog).append("]"); + .append("] rows[").append(rowCount) + .append("] type[").append(desc.getName()) + .append("] predicates[").append(predicates.getLogWhereSql()) + .append("] bind[").append(bindLog).append("]"); return sb.toString(); } @@ -94,7 +94,7 @@ class CQueryFetchSingleAttribute { prepareExecute(); - List result = new ArrayList(); + List result = new ArrayList<>(); while (dataReader.next()) { result.add(scalarType.read(dataReader)); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java index 3b5e8e683..a62ad346f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java @@ -7,7 +7,7 @@ import java.util.Map; /** * Helper to support history functions. */ -public class CQueryHistorySupport { +class CQueryHistorySupport { /** * The DB specific support. @@ -24,7 +24,7 @@ public class CQueryHistorySupport { */ private final String sysPeriod; - public CQueryHistorySupport(DbHistorySupport dbHistorySupport, Map asOfTableMap, String sysPeriod) { + CQueryHistorySupport(DbHistorySupport dbHistorySupport, Map asOfTableMap, String sysPeriod) { this.dbHistorySupport = dbHistorySupport; this.asOfTableMap = asOfTableMap; this.sysPeriod = sysPeriod; @@ -33,37 +33,37 @@ public class CQueryHistorySupport { /** * Return true if the underlying history support is standards based. */ - public boolean isStandardsBased() { + boolean isStandardsBased() { return dbHistorySupport.isStandardsBased(); } /** * Return the 'as of' history view for the given base table. */ - public String getAsOfView(String table) { + String getAsOfView(String table) { return asOfTableMap.get(table); } /** * Return the lower bound column. */ - public String getSysPeriodLower(String tableAlias) { + String getSysPeriodLower(String tableAlias) { return dbHistorySupport.getSysPeriodLower(tableAlias, sysPeriod); } /** * Return the upper bound column. */ - public String getSysPeriodUpper(String tableAlias) { + String getSysPeriodUpper(String tableAlias) { return dbHistorySupport.getSysPeriodUpper(tableAlias, sysPeriod); } /** * Return the predicate appended to the end of the query. - * + *

* Note used for Oracle total recall etc with the more standard approach. */ - public String getAsOfPredicate(String tableAlias) { + String getAsOfPredicate(String tableAlias) { return dbHistorySupport.getAsOfPredicate(tableAlias, sysPeriod); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorSimple.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorSimple.java index 88dba323a..fac87a5a6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorSimple.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorSimple.java @@ -1,12 +1,11 @@ package com.avaje.ebeaninternal.server.query; -import java.sql.SQLException; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.QueryIterator; import com.avaje.ebeaninternal.server.core.OrmQueryRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; + /** * QueryIterator that does not require a buffer for secondary queries. */ @@ -44,4 +43,4 @@ class CQueryIteratorSimple implements QueryIterator { public void remove() { throw new PersistenceException("Remove not allowed"); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java index 163fdfc2f..1ffdeac1c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java @@ -1,13 +1,12 @@ package com.avaje.ebeaninternal.server.query; -import java.sql.SQLException; -import java.util.ArrayList; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.QueryIterator; import com.avaje.ebeaninternal.server.core.OrmQueryRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.ArrayList; + /** * A QueryIterator that uses a buffer to execute secondary queries periodically. */ @@ -24,7 +23,7 @@ class CQueryIteratorWithBuffer implements QueryIterator { this.cquery = cquery; this.request = request; this.bufferSize = bufferSize; - this.buffer = new ArrayList(bufferSize); + this.buffer = new ArrayList<>(bufferSize); } @SuppressWarnings("unchecked") @@ -64,4 +63,4 @@ class CQueryIteratorWithBuffer implements QueryIterator { public void remove() { throw new PersistenceException("Remove not allowed"); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java index 9e925fb52..0d8be611b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; - import com.avaje.ebean.OrderBy; import com.avaje.ebean.OrderBy.Property; import com.avaje.ebeaninternal.api.SpiQuery; @@ -11,10 +9,12 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssoc; import com.avaje.ebeaninternal.server.deploy.id.IdBinder; import com.avaje.ebeaninternal.server.el.ElPropertyValue; +import java.util.List; + /** * Creates the order by expression clause. */ -public class CQueryOrderBy { +class CQueryOrderBy { private final BeanDescriptor desc; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java index 6c490bf17..e20e9c491 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java @@ -5,16 +5,16 @@ import com.avaje.ebean.config.dbplatform.SqlLimitResponse; import com.avaje.ebeaninternal.api.CQueryPlanKey; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.server.core.OrmQueryRequest; +import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.query.CQueryPlanStats.Snapshot; import com.avaje.ebeaninternal.server.type.DataBind; import com.avaje.ebeaninternal.server.type.DataReader; -import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import com.avaje.ebeaninternal.server.type.RsetDataReader; +import com.avaje.ebeaninternal.server.util.Md5; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.security.MessageDigest; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -80,38 +80,32 @@ public class CQueryPlan { /** * Create a query plan based on a OrmQueryRequest. */ - public CQueryPlan(OrmQueryRequest request, SqlLimitResponse sqlRes, SqlTree sqlTree, boolean rawSql, String logWhereSql) { + CQueryPlan(OrmQueryRequest request, SqlLimitResponse sqlRes, SqlTree sqlTree, boolean rawSql, String logWhereSql) { this.server = request.getServer(); this.dataTimeZone = server.getDataTimeZone(); this.beanType = request.getBeanDescriptor().getBeanType(); - this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins()); this.planKey = request.getQueryPlanKey(); this.autoTuned = request.getQuery().isAutoTuned(); this.asOfTableCount = request.getQuery().getAsOfTableCount(); - if (sqlRes != null) { - this.sql = sqlRes.getSql(); - this.rowNumberIncluded = sqlRes.isIncludesRowNumberColumn(); - } else { - this.sql = null; - this.rowNumberIncluded = false; - } + this.sql = sqlRes.getSql(); + this.rowNumberIncluded = sqlRes.isIncludesRowNumberColumn(); this.sqlTree = sqlTree; this.rawSql = rawSql; this.logWhereSql = logWhereSql; this.encryptedProps = sqlTree.getEncryptedProps(); + this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins()); } /** * Create a query plan for a raw sql query. */ - public CQueryPlan(OrmQueryRequest request, String sql, SqlTree sqlTree, - boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { + CQueryPlan(OrmQueryRequest request, String sql, SqlTree sqlTree, + boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { this.server = request.getServer(); this.dataTimeZone = server.getDataTimeZone(); this.beanType = request.getBeanDescriptor().getBeanType(); - this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins()); this.planKey = buildPlanKey(sql, rawSql, rowNumberIncluded, logWhereSql); this.autoTuned = false; this.asOfTableCount = 0; @@ -121,6 +115,7 @@ public class CQueryPlan { this.rowNumberIncluded = rowNumberIncluded; this.logWhereSql = logWhereSql; this.encryptedProps = sqlTree.getEncryptedProps(); + this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins()); } @@ -144,33 +139,33 @@ public class CQueryPlan { /** * Bind keys for encrypted properties if necessary returning the DataBind. */ - public DataBind bindEncryptedProperties(PreparedStatement stmt, Connection conn) throws SQLException { + DataBind bindEncryptedProperties(PreparedStatement stmt, Connection conn) throws SQLException { DataBind dataBind = new DataBind(dataTimeZone, stmt, conn); if (encryptedProps != null) { - for (int i = 0; i < encryptedProps.length; i++) { - String key = encryptedProps[i].getEncryptKey().getStringValue(); + for (BeanProperty encryptedProp : encryptedProps) { + String key = encryptedProp.getEncryptKey().getStringValue(); dataBind.setString(key); } } return dataBind; } - public int getAsOfTableCount() { + int getAsOfTableCount() { return asOfTableCount; } - public boolean isAutoTuned() { + boolean isAutoTuned() { return autoTuned; } - public CQueryPlanKey getPlanKey() { + CQueryPlanKey getPlanKey() { return planKey; } /** * Return a key used in audit logging to identify the query. */ - public String getAuditQueryKey() { + String getAuditQueryKey() { if (auditQueryHash == null) { // volatile object assignment (so happy for multithreaded access) auditQueryHash = calcAuditQueryKey(); @@ -188,32 +183,18 @@ public class CQueryPlan { */ private String getSqlMd5Hash() { try { - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] digest = md.digest(sql.getBytes("UTF-8")); - return digestToHex(digest); + return Md5.hash(sql); } catch (Exception e) { logger.error("Failed to MD5 hash the rawSql query", e); return "error"; } } - /** - * Convert the digest into a hex value. - */ - private String digestToHex(byte[] digest) { - - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < digest.length; i++) { - sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1)); - } - return sb.toString(); - } - public String getSql() { return sql; } - public SqlTree getSqlTree() { + SqlTree getSqlTree() { return sqlTree; } @@ -221,11 +202,11 @@ public class CQueryPlan { return rawSql; } - public boolean isRowNumberIncluded() { + boolean isRowNumberIncluded() { return rowNumberIncluded; } - public String getLogWhereSql() { + String getLogWhereSql() { return logWhereSql; } @@ -239,7 +220,7 @@ public class CQueryPlan { /** * Register an execution time against this query plan; */ - public void executionTime(long loadedBeanCount, long timeMicros, ObjectGraphNode objectGraphNode) { + void executionTime(long loadedBeanCount, long timeMicros, ObjectGraphNode objectGraphNode) { stats.add(loadedBeanCount, timeMicros, objectGraphNode); if (objectGraphNode != null) { @@ -266,7 +247,7 @@ public class CQueryPlan { return stats.getLastQueryTime(); } - public BeanProperty getSingleProperty() { + BeanProperty getSingleProperty() { return sqlTree.getRootNode().getSingleProperty(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java index b23cc79ac..2f0ec4a51 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java @@ -12,11 +12,11 @@ import java.util.List; /** * RawSql based query plan. */ -public class CQueryPlanRawSql extends CQueryPlan { +class CQueryPlanRawSql extends CQueryPlan { private final int[] rsetIndexPositions; - public CQueryPlanRawSql(OrmQueryRequest request, SqlLimitResponse sqlRes, SqlTree sqlTree, String logWhereSql) { + CQueryPlanRawSql(OrmQueryRequest request, SqlLimitResponse sqlRes, SqlTree sqlTree, String logWhereSql) { super(request, sqlRes, sqlTree, true, logWhereSql); this.rsetIndexPositions = createIndexPositions(request, sqlTree); } @@ -35,7 +35,13 @@ public class CQueryPlanRawSql extends CQueryPlan { // set the resultSet index positions for the property expressions for (int i = 0; i < chain.size(); i++) { - indexPositions[i] = 1 + columnMapping.getIndexPosition(chain.get(i)); + String logicalPropertyPath = chain.get(i); + int mappedPosition = columnMapping.getIndexPosition(logicalPropertyPath); + if (mappedPosition == -1 && logicalPropertyPath.endsWith(".id")) { + // try a automatically mapped foreign key + mappedPosition = columnMapping.getIndexPosition(foreignKeyPath(logicalPropertyPath)); + } + indexPositions[i] = 1 + mappedPosition; } // check and handle the case where a discriminator column for @@ -51,4 +57,12 @@ public class CQueryPlanRawSql extends CQueryPlan { return indexPositions; } + + /** + * Return the path for a foreign key column that was automatically mapped. + */ + private String foreignKeyPath(String logicalPropertyPath) { + // trim the .id and replace with Id ... to reverse the auto fk mapping earlier + return logicalPropertyPath.substring(0, logicalPropertyPath.length() - 3) + "Id"; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java index 88389ed8a..36a55fcc9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java @@ -37,10 +37,10 @@ public final class CQueryPlanStats { /** * Construct for a given query plan. */ - public CQueryPlanStats(CQueryPlan queryPlan, boolean collectQueryOrigins) { + CQueryPlanStats(CQueryPlan queryPlan, boolean collectQueryOrigins) { this.queryPlan = queryPlan; - this.origins = !collectQueryOrigins ? null : new ConcurrentHashMap(); + this.origins = !collectQueryOrigins ? null : new ConcurrentHashMap<>(); } /** @@ -92,14 +92,14 @@ public final class CQueryPlanStats { /** * Return the last time this query was executed. */ - public long getLastQueryTime() { + long getLastQueryTime() { return lastQueryTime; } /** * Return a Snapshot of the query execution statistics potentially resetting the internal counters. */ - public Snapshot getSnapshot(boolean reset) { + Snapshot getSnapshot(boolean reset) { List origins = getOrigins(reset); @@ -119,7 +119,7 @@ public final class CQueryPlanStats { return Collections.emptyList(); } - List list = new ArrayList(); + List list = new ArrayList<>(); for (Entry entry : origins.entrySet()) { if (reset) { @@ -138,7 +138,7 @@ public final class CQueryPlanStats { private final ObjectGraphNode objectGraphNode; private final long count; - public OriginSnapshot(ObjectGraphNode objectGraphNode, long count) { + OriginSnapshot(ObjectGraphNode objectGraphNode, long count) { this.objectGraphNode = objectGraphNode; this.count = count; } @@ -172,8 +172,8 @@ public final class CQueryPlanStats { private final long lastQueryTime; private final List origins; - public Snapshot(CQueryPlan queryPlan, long count, long totalTime, long totalBeans, long maxTime, long startTime, long lastQueryTime, - List origins) { + Snapshot(CQueryPlan queryPlan, long count, long totalTime, long totalBeans, long maxTime, long startTime, long lastQueryTime, + List origins) { this.queryPlan = queryPlan; this.count = count; @@ -187,7 +187,7 @@ public final class CQueryPlanStats { public String toString() { return queryPlan + " count:" + count + " time:" + totalTime + " maxTime:" + maxTime + " beans:" + totalBeans - + " start:" + startTime + " lastQuery:" + lastQueryTime + " origins:" + origins; + + " start:" + startTime + " lastQuery:" + lastQueryTime + " origins:" + origins; } @Override @@ -257,4 +257,4 @@ public final class CQueryPlanStats { } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java index 52f4aec9d..dcd59eaa3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java @@ -106,7 +106,7 @@ public class CQueryPredicates { private Set orderByIncludes; - public CQueryPredicates(Binder binder, OrmQueryRequest request) { + CQueryPredicates(Binder binder, OrmQueryRequest request) { this.binder = binder; this.request = request; this.query = request.getQuery(); @@ -114,7 +114,7 @@ public class CQueryPredicates { this.idValue = query.getId(); } - public String bind(PreparedStatement stmt, Connection connection) throws SQLException { + public String bind(PreparedStatement stmt, Connection connection) throws SQLException { return bind(binder.dataBind(stmt, connection)); } @@ -152,6 +152,7 @@ public class CQueryPredicates { // this is a find by id type query... request.getBeanDescriptor().bindId(dataBind, idValue); dataBind.append(idValue); + dataBind.append(", "); } if (bindParams != null) { @@ -252,7 +253,7 @@ public class CQueryPredicates { } // create a copy of the includes required to support the orderBy - orderByIncludes = new HashSet(deployParser.getIncludes()); + orderByIncludes = new HashSet<>(deployParser.getIncludes()); dbWhere = deriveWhere(deployParser); dbFilterMany = deriveFilterMany(deployParser); @@ -277,7 +278,7 @@ public class CQueryPredicates { /** * Replace the table alias place holders. */ - public void parseTableAlias(SqlTreeAlias alias) { + void parseTableAlias(SqlTreeAlias alias) { if (dbWhere != null) { // use the where table alias dbWhere = alias.parseWhere(dbWhere); @@ -399,53 +400,53 @@ public class CQueryPredicates { /** * Return the db update set clause for an UpdateQuery. */ - public String getDbUpdateClause() { + String getDbUpdateClause() { return dbUpdateClause; } /** * Return the db column version of the combined where clause. */ - public String getDbHaving() { + String getDbHaving() { return dbHaving; } /** * Return the db column version of the combined where clause. */ - public String getDbWhere() { + String getDbWhere() { return dbWhere; } /** * Return a db filter for filtering many fetch joins. */ - public String getDbFilterMany() { + String getDbFilterMany() { return dbFilterMany; } /** * Return the db column version of the order by clause. */ - public String getDbOrderBy() { + String getDbOrderBy() { return dbOrderBy; } /** * Return the includes required for the where and order by clause. */ - public Set getPredicateIncludes() { + Set getPredicateIncludes() { return predicateIncludes; } /** * Return the orderBy includes. */ - public Set getOrderByIncludes() { + Set getOrderByIncludes() { return orderByIncludes; } - public String getLogWhereSql() { + String getLogWhereSql() { if (dbWhere == null && dbFilterMany == null) { return ""; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java index 8949b4868..e3011c17c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java @@ -14,7 +14,7 @@ import java.sql.SQLException; /** * Executes the select row count query. */ -public class CQueryRowCount { +class CQueryRowCount { /** * The overall find request wrapper object. @@ -54,16 +54,13 @@ public class CQueryRowCount { /** * Create the Sql select based on the request. */ - public CQueryRowCount(OrmQueryRequest request, CQueryPredicates predicates, String sql) { + CQueryRowCount(OrmQueryRequest request, CQueryPredicates predicates, String sql) { this.request = request; this.query = request.getQuery(); this.sql = sql; - query.setGeneratedSql(sql); - this.desc = request.getBeanDescriptor(); this.predicates = predicates; - } /** @@ -73,10 +70,10 @@ public class CQueryRowCount { //noinspection StringBufferReplaceableByString StringBuilder sb = new StringBuilder(80); sb.append("FindRowCount exeMicros[").append(executionTimeMicros) - .append("] rows[").append(rowCount) - .append("] type[").append(desc.getFullName()) - .append("] predicates[").append(predicates.getLogWhereSql()) - .append("] bind[").append(bindLog).append("]"); + .append("] rows[").append(rowCount) + .append("] type[").append(desc.getFullName()) + .append("] predicates[").append(predicates.getLogWhereSql()) + .append("] bind[").append(bindLog).append("]"); return sb.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java index e8a012af4..fb1abb580 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java @@ -12,7 +12,7 @@ import java.sql.SQLException; /** * Executes the delete query. */ -public class CQueryUpdate { +class CQueryUpdate { private final OrmQueryRequest request; @@ -46,7 +46,7 @@ public class CQueryUpdate { /** * Create the Sql select based on the request. */ - public CQueryUpdate(String type, OrmQueryRequest request, CQueryPredicates predicates, String sql) { + CQueryUpdate(String type, OrmQueryRequest request, CQueryPredicates predicates, String sql) { this.type = type; this.request = request; this.query = request.getQuery(); @@ -62,10 +62,10 @@ public class CQueryUpdate { public String getSummary() { StringBuilder sb = new StringBuilder(80); sb.append(type).append(" exeMicros[").append(executionTimeMicros) - .append("] rows[").append(rowCount) - .append("] type[").append(desc.getName()) - .append("] predicates[").append(predicates.getLogWhereSql()) - .append("] bind[").append(bindLog).append("]"); + .append("] rows[").append(rowCount) + .append("] type[").append(desc.getName()) + .append("] predicates[").append(predicates.getLogWhereSql()) + .append("] bind[").append(bindLog).append("]"); return sb.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQuery.java b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQuery.java index 2afca3a7b..31683d361 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQuery.java @@ -10,7 +10,7 @@ import com.avaje.ebeaninternal.api.SpiQuery; * @param the entity bean type * @author rbygrave */ -public abstract class CallableQuery { +abstract class CallableQuery { protected final SpiQuery query; @@ -18,7 +18,7 @@ public abstract class CallableQuery { protected final Transaction transaction; - public CallableQuery(SpiEbeanServer server, SpiQuery query, Transaction t) { + CallableQuery(SpiEbeanServer server, SpiQuery query, Transaction t) { this.server = server; this.query = query; this.transaction = t; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryIds.java b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryIds.java index cfd1a7aa6..d8a6aec89 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryIds.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; -import java.util.concurrent.Callable; - import com.avaje.ebean.Transaction; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiQuery; +import java.util.List; +import java.util.concurrent.Callable; + /** * Represent the fetch Id's query as a Callable. * diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryList.java b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryList.java index 8a1ed154e..352c63e8e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryList.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; -import java.util.concurrent.Callable; - import com.avaje.ebean.Transaction; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiQuery; +import java.util.List; +import java.util.concurrent.Callable; + /** * Represent the findList query as a Callable. * diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryRowCount.java b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryRowCount.java index 0eeeb105f..d583675da 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryRowCount.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryRowCount.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.query; -import java.util.concurrent.Callable; - import com.avaje.ebean.Transaction; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiQuery; +import java.util.concurrent.Callable; + /** * Represent the findRowCount query as a Callable. * diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java index ddba62116..e1af25150 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java @@ -9,7 +9,7 @@ import com.avaje.ebeaninternal.server.util.ArrayStack; import java.util.ArrayList; import java.util.HashSet; -public class DefaultDbSqlContext implements DbSqlContext { +class DefaultDbSqlContext implements DbSqlContext { private static final String COMMA = ", "; @@ -20,11 +20,11 @@ public class DefaultDbSqlContext implements DbSqlContext { private final String columnAliasPrefix; - private final ArrayStack tableAliasStack = new ArrayStack(); + private final ArrayStack tableAliasStack = new ArrayStack<>(); - private final ArrayStack joinStack = new ArrayStack(); + private final ArrayStack joinStack = new ArrayStack<>(); - private final ArrayStack prefixStack = new ArrayStack(); + private final ArrayStack prefixStack = new ArrayStack<>(); private boolean useColumnAlias; @@ -54,8 +54,8 @@ public class DefaultDbSqlContext implements DbSqlContext { /** * Construct for SELECT clause (with column alias settings). */ - public DefaultDbSqlContext(SqlTreeAlias alias, String tableAliasPlaceHolder, - String columnAliasPrefix, boolean alwaysUseColumnAlias, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { + DefaultDbSqlContext(SqlTreeAlias alias, String tableAliasPlaceHolder, + String columnAliasPrefix, boolean alwaysUseColumnAlias, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { this.alias = alias; this.tableAliasPlaceHolder = tableAliasPlaceHolder; @@ -73,7 +73,7 @@ public class DefaultDbSqlContext implements DbSqlContext { public void addEncryptedProp(BeanProperty p) { if (encryptedProps == null) { - encryptedProps = new ArrayList(); + encryptedProps = new ArrayList<>(); } encryptedProps.add(p); } @@ -101,7 +101,7 @@ public class DefaultDbSqlContext implements DbSqlContext { public void addJoin(String type, String table, TableJoinColumn[] cols, String a1, String a2, String inheritance) { if (tableJoins == null) { - tableJoins = new HashSet(); + tableJoins = new HashSet<>(); } String joinKey = table + "-" + a1 + "-" + a2; @@ -136,9 +136,20 @@ public class DefaultDbSqlContext implements DbSqlContext { if (i > 0) { sb.append(" and "); } - sb.append(a2).append(".").append(pair.getForeignDbColumn()); + + if (pair.getForeignSqlFormula() != null) { + sb.append(StringHelper.replaceString(pair.getForeignSqlFormula(), tableAliasPlaceHolder, a2)); + } else { + sb.append(a2).append(".").append(pair.getForeignDbColumn()); + } + sb.append(" = "); - sb.append(a1).append(".").append(pair.getLocalDbColumn()); + + if (pair.getLocalSqlFormula() != null) { + sb.append(StringHelper.replaceString(pair.getLocalSqlFormula(), tableAliasPlaceHolder, a1)); + } else { + sb.append(a1).append(".").append(pair.getLocalDbColumn()); + } } // add on any inheritance where clause @@ -213,7 +224,7 @@ public class DefaultDbSqlContext implements DbSqlContext { String converted = StringHelper.replaceString(sqlFormulaJoin, tableAliasPlaceHolder, tableAlias); if (formulaJoins == null) { - formulaJoins = new HashSet(); + formulaJoins = new HashSet<>(); } else if (formulaJoins.contains(converted)) { // skip adding a formula join because @@ -240,10 +251,12 @@ public class DefaultDbSqlContext implements DbSqlContext { String tableAlias = tableAliasStack.peek(); String converted = StringHelper.replaceString(sqlFormulaSelect, tableAliasPlaceHolder, - tableAlias); + tableAlias); sb.append(COMMA); sb.append(converted); + + appendColumnAlias(); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultRelationalQueryEngine.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultRelationalQueryEngine.java index 497e2f173..4193e1ac1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultRelationalQueryEngine.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultRelationalQueryEngine.java @@ -74,7 +74,7 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine { try { request.executeSql(binder); - List rows = new ArrayList(); + List rows = new ArrayList<>(); while (request.next()) { rows.add(readRow(request)); } @@ -102,7 +102,7 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine { /** * Read the row from the ResultSet and return as a MapBean. */ - protected SqlRow readRow(RelationalQueryRequest request) throws SQLException { + private SqlRow readRow(RelationalQueryRequest request) throws SQLException { return request.createNewRow(dbTrueValue); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java index 80e7e8ff6..0cb102c09 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java @@ -1,5 +1,9 @@ package com.avaje.ebeaninternal.server.query; +import com.avaje.ebean.SqlQuery; +import com.avaje.ebean.SqlRow; +import com.avaje.ebeaninternal.server.core.BasicTypeConverter; + import java.math.BigDecimal; import java.sql.Date; import java.sql.Timestamp; @@ -10,10 +14,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import com.avaje.ebean.SqlQuery; -import com.avaje.ebean.SqlRow; -import com.avaje.ebeaninternal.server.core.BasicTypeConverter; - /** * Used to return raw SQL query results. *

@@ -51,7 +51,7 @@ public class DefaultSqlRow implements SqlRow { *

*/ public DefaultSqlRow(int initialCapacity, float loadFactor, String dbTrueValue) { - this.map = new LinkedHashMap(initialCapacity, loadFactor); + this.map = new LinkedHashMap<>(initialCapacity, loadFactor); this.dbTrueValue = dbTrueValue; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedList.java b/src/main/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedList.java index 301fc884f..6dc4e9232 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedList.java @@ -1,15 +1,14 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; -import java.util.concurrent.Future; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.EbeanServer; import com.avaje.ebean.PagedList; import com.avaje.ebeaninternal.api.Monitor; import com.avaje.ebeaninternal.api.SpiQuery; +import javax.persistence.PersistenceException; +import java.util.List; +import java.util.concurrent.Future; + /** * PagedList implementation based on limit offset types of queries. * diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureIds.java b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureIds.java index bf0d595cf..a96a524c9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureIds.java @@ -15,7 +15,7 @@ public class QueryFutureIds extends BaseFuture> implements Futur private final CallableQueryIds call; public QueryFutureIds(CallableQueryIds call) { - super(new FutureTask>(call)); + super(new FutureTask<>(call)); this.call = call; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java index 74779df8c..7f68a84c6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java @@ -1,16 +1,15 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - import com.avaje.ebean.FutureList; import com.avaje.ebean.Query; import com.avaje.ebean.Transaction; import javax.persistence.PersistenceException; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; /** * Default implementation for FutureList. @@ -20,7 +19,7 @@ public class QueryFutureList extends BaseFuture> implements FutureLis private final CallableQueryList call; public QueryFutureList(CallableQueryList call) { - super(new FutureTask>(call)); + super(new FutureTask<>(call)); this.call = call; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java index 970e3fe91..f5202883d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.query; -import java.util.concurrent.FutureTask; - import com.avaje.ebean.FutureRowCount; import com.avaje.ebean.Query; import com.avaje.ebean.Transaction; +import java.util.concurrent.FutureTask; + /** * Future implementation for the row count query. */ @@ -14,7 +14,7 @@ public class QueryFutureRowCount extends BaseFuture implements Futur private final CallableQueryRowCount call; public QueryFutureRowCount(CallableQueryRowCount call) { - super(new FutureTask(call)); + super(new FutureTask<>(call)); this.call = call; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java b/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java index f26301ba3..c04b49430 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java @@ -5,14 +5,14 @@ import com.avaje.ebeaninternal.api.CQueryPlanKey; /** * QueryPlanKey for RawSql queries. */ -public class RawSqlQueryPlanKey implements CQueryPlanKey { +class RawSqlQueryPlanKey implements CQueryPlanKey { private final String sql; private final boolean rawSql; private final boolean rowNumberIncluded; private final String logWhereSql; - public RawSqlQueryPlanKey(String sql, boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { + RawSqlQueryPlanKey(String sql, boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { this.sql = sql; this.rawSql = rawSql; this.rowNumberIncluded = rowNumberIncluded; @@ -48,9 +48,9 @@ public class RawSqlQueryPlanKey implements CQueryPlanKey { @Override public int hashCode() { int result = sql.hashCode(); - result = 31 * result + (rawSql ? 1 : 0); - result = 31 * result + (rowNumberIncluded ? 1 : 0); - result = 31 * result + logWhereSql.hashCode(); + result = 92821 * result + (rawSql ? 1 : 0); + result = 92821 * result + (rowNumberIncluded ? 1 : 0); + result = 92821 * result + logWhereSql.hashCode(); return result; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java index c6395dd37..546dbf4c8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java @@ -26,7 +26,7 @@ public class SqlBeanLoad { private final boolean refreshLoading; private final boolean rawSql; - public SqlBeanLoad(DbReadContext ctx, Class type, EntityBean bean, Mode queryMode) { + SqlBeanLoad(DbReadContext ctx, Class type, EntityBean bean, Mode queryMode) { this.ctx = ctx; this.rawSql = ctx.isRawSql(); @@ -58,8 +58,8 @@ public class SqlBeanLoad { } if ((bean == null) - || (lazyLoading && ebi.isLoadedProperty(prop.getPropertyIndex())) - || (type != null && !prop.isAssignableFrom(type))) { + || (lazyLoading && ebi.isLoadedProperty(prop.getPropertyIndex())) + || (type != null && !prop.isAssignableFrom(type))) { // ignore this property // ... null: bean already in persistence context diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java index 523414f2a..ac9c4f867 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java @@ -11,7 +11,7 @@ import java.util.Set; /** * Represents the SELECT clause part of the SQL query. */ -public class SqlTree { +class SqlTree { private final SqlTreeNode rootNode; @@ -48,8 +48,8 @@ public class SqlTree { /** * Create the SqlSelectClause. */ - public SqlTree(String summary, SqlTreeNode rootNode, String selectSql, String fromSql, String groupBy, String inheritanceWhereSql, - BeanProperty[] encryptedProps, BeanPropertyAssocMany manyProperty, Set includes, boolean includeJoins) { + SqlTree(String summary, SqlTreeNode rootNode, String selectSql, String fromSql, String groupBy, String inheritanceWhereSql, + BeanProperty[] encryptedProps, BeanPropertyAssocMany manyProperty, Set includes, boolean includeJoins) { this.summary = summary; this.rootNode = rootNode; @@ -66,21 +66,21 @@ public class SqlTree { /** * Return true if the query includes joins (not valid for rawSql). */ - public boolean isIncludeJoins() { + boolean isIncludeJoins() { return includeJoins; } /** * Recurse through the tree adding an table alias' for @History entity beans. */ - public void addAsOfTableAlias(SpiQuery query) { + void addAsOfTableAlias(SpiQuery query) { rootNode.addAsOfTableAlias(query); } /** * Recurse through the tree adding soft delete predicates as necessary. */ - public void addSoftDeletePredicate(SpiQuery query) { + void addSoftDeletePredicate(SpiQuery query) { rootNode.addSoftDeletePredicate(query); } @@ -88,7 +88,7 @@ public class SqlTree { * Build a select expression chain for RawSql. */ public List buildRawSqlSelectChain() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); rootNode.buildRawSqlSelectChain(list); return list; } @@ -103,25 +103,25 @@ public class SqlTree { /** * Return the String for the actual SQL. */ - public String getSelectSql() { + String getSelectSql() { return selectSql; } - public String getFromSql() { + String getFromSql() { return fromSql; } /** * Return the groupBy clause. */ - public String getGroupBy() { + String getGroupBy() { return groupBy; } /** * Return the where clause for inheritance. */ - public String getInheritanceWhereSql() { + String getInheritanceWhereSql() { return inheritanceWhereSql; } @@ -132,7 +132,7 @@ public class SqlTree { return summary; } - public SqlTreeNode getRootNode() { + SqlTreeNode getRootNode() { return rootNode; } @@ -140,18 +140,18 @@ public class SqlTree { * Return the property that is associated with the many. There can only be one * per SqlSelect. This can be null. */ - public BeanPropertyAssocMany getManyProperty() { + BeanPropertyAssocMany getManyProperty() { return manyProperty; } - public BeanProperty[] getEncryptedProps() { + BeanProperty[] getEncryptedProps() { return encryptedProps; } /** * Return true if the query has a many join. */ - public boolean hasMany() { + boolean hasMany() { return manyProperty != null || rootNode.hasMany(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeAlias.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeAlias.java index 1fe2b1a7f..5f06cb226 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeAlias.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeAlias.java @@ -13,32 +13,32 @@ import java.util.TreeSet; /** * Special Map of the logical property joins to table alias. */ -public class SqlTreeAlias { +class SqlTreeAlias { private int counter; private int manyWhereCounter; - private final TreeSet joinProps = new TreeSet(); + private final TreeSet joinProps = new TreeSet<>(); private HashSet embeddedPropertyJoins; - private final TreeSet manyWhereJoinProps = new TreeSet(); + private final TreeSet manyWhereJoinProps = new TreeSet<>(); - private final HashMap aliasMap = new HashMap(); + private final HashMap aliasMap = new HashMap<>(); - private final HashMap manyWhereAliasMap = new HashMap(); + private final HashMap manyWhereAliasMap = new HashMap<>(); private final String rootTableAlias; - public SqlTreeAlias(String rootTableAlias) { + SqlTreeAlias(String rootTableAlias) { this.rootTableAlias = rootTableAlias; } /** * Add joins to support where predicates */ - public void addManyWhereJoins(Set manyWhereJoins) { + void addManyWhereJoins(Set manyWhereJoins) { if (manyWhereJoins != null) { for (String include : manyWhereJoins) { addPropertyJoin(include, manyWhereJoinProps); @@ -48,7 +48,7 @@ public class SqlTreeAlias { private void addEmbeddedPropertyJoin(String embProp) { if (embeddedPropertyJoins == null) { - embeddedPropertyJoins = new HashSet(); + embeddedPropertyJoins = new HashSet<>(); } embeddedPropertyJoins.add(embProp); } @@ -85,7 +85,7 @@ public class SqlTreeAlias { /** * Build a set of table alias for the given bean and fetch joined properties. */ - public void buildAlias() { + void buildAlias() { for (String joinProp : joinProps) { calcAlias(joinProp); @@ -125,7 +125,7 @@ public class SqlTreeAlias { /** * Return the table alias for a given property name. */ - public String getTableAlias(String prefix) { + String getTableAlias(String prefix) { if (prefix == null) { return rootTableAlias; } else { @@ -140,7 +140,7 @@ public class SqlTreeAlias { /** * Return an alias using "Many where joins". */ - public String getTableAliasManyWhere(String prefix) { + String getTableAliasManyWhere(String prefix) { if (prefix == null) { return rootTableAlias; } @@ -158,7 +158,7 @@ public class SqlTreeAlias { /** * Parse for where clauses that uses "Many where joins" */ - public String parseWhere(String clause) { + String parseWhere(String clause) { clause = parseRootAlias(clause); clause = parseAliasMap(clause, manyWhereAliasMap); return parseAliasMap(clause, aliasMap); @@ -211,7 +211,7 @@ public class SqlTreeAlias { /** * Return true if there are joins included in the query. */ - public boolean isIncludeJoins() { + boolean isIncludeJoins() { return !aliasMap.isEmpty() || !manyWhereAliasMap.isEmpty(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java index ff3597337..6e7b7e660 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java @@ -55,7 +55,7 @@ public class SqlTreeBuilder { private final DefaultDbSqlContext ctx; - private final HashSet selectIncludes = new HashSet(); + private final HashSet selectIncludes = new HashSet<>(); private final ManyWhereJoins manyWhereJoins; @@ -139,10 +139,10 @@ public class SqlTreeBuilder { encryptedProps = ctx.getEncryptedProps(); } - boolean includeJoins = (alias == null) ? false : alias.isIncludeJoins(); + boolean includeJoins = alias != null && alias.isIncludeJoins(); return new SqlTree(summary.toString(), rootNode, selectSql, fromSql, groupBy, inheritanceWhereSql, encryptedProps, - manyProperty, queryDetail.getFetchPaths(), includeJoins); + manyProperty, queryDetail.getFetchPaths(), includeJoins); } private String buildSelectClause() { @@ -216,23 +216,23 @@ public class SqlTreeBuilder { private SqlTreeNode buildSelectChain(String prefix, BeanPropertyAssoc prop, BeanDescriptor desc, List joinList) { - List myJoinList = new ArrayList(); + List myJoinList = new ArrayList<>(); BeanPropertyAssocOne[] ones = desc.propertiesOne(); - for (int i = 0; i < ones.length; i++) { - String propPrefix = SplitName.add(prefix, ones[i].getName()); + for (BeanPropertyAssocOne one : ones) { + String propPrefix = SplitName.add(prefix, one.getName()); if (isIncludeBean(propPrefix)) { selectIncludes.add(propPrefix); - buildSelectChain(propPrefix, ones[i], ones[i].getTargetDescriptor(), myJoinList); + buildSelectChain(propPrefix, one, one.getTargetDescriptor(), myJoinList); } } BeanPropertyAssocMany[] manys = desc.propertiesMany(); - for (int i = 0; i < manys.length; i++) { - String propPrefix = SplitName.add(prefix, manys[i].getName()); - if (isIncludeMany(propPrefix, manys[i])) { + for (BeanPropertyAssocMany many : manys) { + String propPrefix = SplitName.add(prefix, many.getName()); + if (isIncludeMany(propPrefix, many)) { selectIncludes.add(propPrefix); - buildSelectChain(propPrefix, manys[i], manys[i].getTargetDescriptor(), myJoinList); + buildSelectChain(propPrefix, many, many.getTargetDescriptor(), myJoinList); } } @@ -458,18 +458,16 @@ public class SqlTreeBuilder { selectProps.add(desc.propertiesEmbedded()); BeanPropertyAssocOne[] propertiesOne = desc.propertiesOne(); - for (int i = 0; i < propertiesOne.length; i++) { + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { //noinspection StatementWithEmptyBody - if (queryProps != null && queryProps.isIncludedBeanJoin(propertiesOne[i].getName())) { + if (queryProps != null && queryProps.isIncludedBeanJoin(aPropertiesOne.getName())) { // if it is a joined bean... then don't add the property // as it will have its own entire Node in the SqlTree } else { - selectProps.add(propertiesOne[i]); + selectProps.add(aPropertiesOne); } } - selectProps.setTableJoins(desc.tableJoins()); - InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo != null) { // add sub type properties @@ -542,12 +540,12 @@ public class SqlTreeBuilder { /** * Contains the 'root' extra joins. We only return the roots back. */ - private final Map joinRegister = new HashMap(); + private final Map joinRegister = new HashMap<>(); /** * Register of all the extra join nodes. */ - private final Map rootRegister = new HashMap(); + private final Map rootRegister = new HashMap<>(); private final BeanDescriptor desc; @@ -578,8 +576,8 @@ public class SqlTreeBuilder { Arrays.sort(extras); // reverse order so get the leaves first... - for (int i = 0; i < extras.length; i++) { - createExtraJoin(extras[i]); + for (String extra : extras) { + createExtraJoin(extra); } return rootRegister.values(); @@ -668,7 +666,7 @@ public class SqlTreeBuilder { */ private String[] findExtras() { - List extras = new ArrayList(); + List extras = new ArrayList<>(); for (String predProp : predicateIncludes) { if (!selectIncludes.contains(predProp)) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java index aa7031b1b..bfd69c980 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java @@ -89,7 +89,7 @@ class SqlTreeNodeBean implements SqlTreeNode { * Construct for leaf node. */ SqlTreeNodeBean(String prefix, BeanPropertyAssoc beanProp, SqlTreeProperties props, - List myChildren, boolean disableLazyLoad) { + List myChildren, boolean disableLazyLoad) { this(prefix, beanProp, beanProp.getTargetDescriptor(), props, myChildren, true, null, SpiQuery.TemporalMode.CURRENT, disableLazyLoad); } @@ -98,7 +98,7 @@ class SqlTreeNodeBean implements SqlTreeNode { * Construct for root node. */ SqlTreeNodeBean(BeanDescriptor desc, SqlTreeProperties props, List myList, boolean withId, - BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { + BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { this(null, null, desc, props, myList, withId, many, temporalMode, disableLazyLoad); } @@ -142,9 +142,9 @@ class SqlTreeNodeBean implements SqlTreeNode { BeanPropertyAssocMany[] manys = desc.propertiesMany(); - HashMap m = new HashMap(); - for (int i = 0; i < manys.length; i++) { - String name = manys[i].getName(); + HashMap m = new HashMap<>(); + for (BeanPropertyAssocMany many : manys) { + String name = many.getName(); m.put(name, getPath(prefix, name)); } @@ -167,14 +167,14 @@ class SqlTreeNodeBean implements SqlTreeNode { } idBinder.buildRawSqlSelectChain(prefix, selectChain); } - for (int i = 0, x = properties.length; i < x; i++) { - properties[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty property : properties) { + property.buildRawSqlSelectChain(prefix, selectChain); } // recursively continue reading... - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].buildRawSqlSelectChain(selectChain); + aChildren.buildRawSqlSelectChain(selectChain); } } @@ -190,7 +190,7 @@ class SqlTreeNodeBean implements SqlTreeNode { Timestamp end = ctx.getDataReader().getTimestamp(); T bean = (T) load(ctx, null, null); - return new Version(bean, start, end); + return new Version<>(bean, start, end); } /** @@ -269,20 +269,20 @@ class SqlTreeNodeBean implements SqlTreeNode { if (inheritInfo == null) { // normal behavior with no inheritance - for (int i = 0, x = properties.length; i < x; i++) { - properties[i].load(sqlBeanLoad); + for (BeanProperty property : properties) { + property.load(sqlBeanLoad); } } else { // take account of inheritance and due to subclassing approach // need to get a 'local' version of the property - for (int i = 0, x = properties.length; i < x; i++) { + for (BeanProperty property : properties) { // get a local version of the BeanProperty - BeanProperty p = localDesc.getBeanProperty(properties[i].getName()); + BeanProperty p = localDesc.getBeanProperty(property.getName()); if (p != null) { p.load(sqlBeanLoad); } else { - properties[i].loadIgnore(ctx); + property.loadIgnore(ctx); } } } @@ -295,10 +295,10 @@ class SqlTreeNodeBean implements SqlTreeNode { } // recursively continue reading... - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].load(ctx, localBean, contextBean); + aChildren.load(ctx, localBean, contextBean); } if (!lazyLoadMany && localBean != null) { @@ -367,17 +367,17 @@ class SqlTreeNodeBean implements SqlTreeNode { // load the List/Set/Map proxy objects (deferred fetching of lists) BeanPropertyAssocMany[] manys = localDesc.propertiesMany(); - for (int i = 0; i < manys.length; i++) { + for (BeanPropertyAssocMany many : manys) { - if (fetchedMany == null || !fetchedMany.equals(manys[i])) { + if (fetchedMany == null || !fetchedMany.equals(many)) { // create a proxy for the many (deferred fetching) - BeanCollection ref = manys[i].createReferenceIfNull(localBean); + BeanCollection ref = many.createReferenceIfNull(localBean); if (ref != null) { if (disableLazyLoad) { ref.setDisableLazyLoad(true); } if (!ref.isRegisteredWithLoadContext()) { - ctx.register(manys[i].getName(), ref); + ctx.register(many.getName(), ref); } } } @@ -392,9 +392,9 @@ class SqlTreeNodeBean implements SqlTreeNode { if (readId) { appendSelectId(ctx, idBinder.getBeanProperty()); } - for (int i = 0; i < properties.length; i++) { - if (!properties[i].isAggregation()) { - properties[i].appendSelect(ctx, subQuery); + for (BeanProperty property : properties) { + if (!property.isAggregation()) { + property.appendSelect(ctx, subQuery); } } ctx.popTableAlias(); @@ -427,10 +427,10 @@ class SqlTreeNodeBean implements SqlTreeNode { } appendSelect(ctx, subQuery, properties); - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].appendSelect(ctx, subQuery); + aChildren.appendSelect(ctx, subQuery); } ctx.popTableAlias(); @@ -446,8 +446,8 @@ class SqlTreeNodeBean implements SqlTreeNode { */ private void appendSelect(DbSqlContext ctx, boolean subQuery, BeanProperty[] props) { - for (int i = 0; i < props.length; i++) { - props[i].appendSelect(ctx, subQuery); + for (BeanProperty prop : props) { + prop.appendSelect(ctx, subQuery); } } @@ -480,10 +480,10 @@ class SqlTreeNodeBean implements SqlTreeNode { ctx.append(" ").append(ew).append(" "); } - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // recursively add to the where clause any // fixed predicates (extraWhere etc) - children[i].appendWhere(ctx); + aChildren.appendWhere(ctx); } } @@ -500,13 +500,13 @@ class SqlTreeNodeBean implements SqlTreeNode { // join and return SqlJoinType to use for child joins joinType = appendFromBaseTable(ctx, joinType); - for (int i = 0; i < properties.length; i++) { + for (BeanProperty property : properties) { // usually nothing... except for 1-1 Exported - properties[i].appendFrom(ctx, joinType); + property.appendFrom(ctx, joinType); } - for (int i = 0; i < children.length; i++) { - children[i].appendFrom(ctx, joinType); + for (SqlTreeNode aChildren : children) { + aChildren.appendFrom(ctx, joinType); } ctx.popTableAlias(); @@ -532,8 +532,8 @@ class SqlTreeNodeBean implements SqlTreeNode { if (intersectionAsOfTableAlias) { query.incrementAsOfTableCount(); } - for (int i = 0; i < children.length; i++) { - children[i].addAsOfTableAlias(query); + for (SqlTreeNode aChildren : children) { + aChildren.addAsOfTableAlias(query); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java index cd31bc405..b605d51f2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java @@ -77,7 +77,7 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { * This means we need to add distinct to the sql query. *

*/ - public boolean isManyJoin() { + boolean isManyJoin() { return manyJoin; } @@ -87,7 +87,7 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { public void addChild(SqlTreeNodeExtraJoin child) { if (children == null) { - children = new ArrayList(); + children = new ArrayList<>(); } children.add(child); } @@ -129,8 +129,7 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { joinType = joinType.autoToOuter(); } - for (int i = 0; i < children.size(); i++) { - SqlTreeNodeExtraJoin child = children.get(i); + for (SqlTreeNodeExtraJoin child : children) { child.appendFrom(ctx, joinType); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java index a753d5a25..30d0d2301 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java @@ -30,7 +30,7 @@ class SqlTreeNodeManyWhereJoin implements SqlTreeNode { */ private final SqlJoinType manyJoinType; - public SqlTreeNodeManyWhereJoin(String prefix, BeanPropertyAssoc prop, SqlJoinType manyJoinType) { + SqlTreeNodeManyWhereJoin(String prefix, BeanPropertyAssoc prop, SqlJoinType manyJoinType) { this.nodeBeanProp = prop; this.prefix = prefix; @@ -80,7 +80,7 @@ class SqlTreeNodeManyWhereJoin implements SqlTreeNode { * Join to base table for this node. This includes a join to the * intersection table if this is a ManyToMany node. */ - public void appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) { + void appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) { String alias = ctx.getTableAliasManyWhere(prefix); String parentAlias = ctx.getTableAliasManyWhere(parentPrefix); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java index a0b386b81..d75fbb140 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java @@ -18,8 +18,8 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean { /** * Specify for SqlSelect to include an Id property or not. */ - public SqlTreeNodeRoot(BeanDescriptor desc, SqlTreeProperties props, List myList, boolean withId, - TableJoin includeJoin, BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { + SqlTreeNodeRoot(BeanDescriptor desc, SqlTreeProperties props, List myList, boolean withId, + TableJoin includeJoin, BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { super(desc, props, myList, withId, many, temporalMode, disableLazyLoad); this.includeJoin = includeJoin; @@ -36,8 +36,8 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean { if (lazyLoadParent != null && lazyLoadParent.isManyToManyWithHistory()) { query.incrementAsOfTableCount(); } - for (int i = 0; i < children.length; i++) { - children[i].addAsOfTableAlias(query); + for (SqlTreeNode aChildren : children) { + aChildren.addAsOfTableAlias(query); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java index 8b519f851..e674f3146 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java @@ -1,52 +1,47 @@ package com.avaje.ebeaninternal.server.query; +import com.avaje.ebeaninternal.api.ManyWhereJoins; +import com.avaje.ebeaninternal.server.deploy.BeanProperty; + import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; -import com.avaje.ebeaninternal.api.ManyWhereJoins; -import com.avaje.ebeaninternal.server.deploy.BeanProperty; -import com.avaje.ebeaninternal.server.deploy.TableJoin; - /** * The select properties for a node in the SqlTree. */ public class SqlTreeProperties { - private static final TableJoin[] EMPTY_TABLE_JOINS = new TableJoin[0]; - /** * True if this node of the tree should have read only entity beans. */ private boolean readOnly; - private TableJoin[] tableJoins = EMPTY_TABLE_JOINS; - /** * The bean properties in order. */ - private final List propsList = new ArrayList(); + private final List propsList = new ArrayList<>(); /** * Maintain a list of property names to detect embedded bean additions. */ - private final LinkedHashSet propNames = new LinkedHashSet(); + private final LinkedHashSet propNames = new LinkedHashSet<>(); private boolean allProperties; private boolean aggregation; - public SqlTreeProperties() { + SqlTreeProperties() { } - public boolean containsProperty(String propName) { + boolean containsProperty(String propName) { return propNames.contains(propName); } public void add(BeanProperty[] props) { //noinspection ManualArrayToCollectionCopy - for (int i = 0; i < props.length; i++) { - propsList.add(props[i]); + for (BeanProperty prop : props) { + propsList.add(prop); } } @@ -59,7 +54,7 @@ public class SqlTreeProperties { return propsList.toArray(new BeanProperty[propsList.size()]); } - public boolean isPartialObject() { + boolean isPartialObject() { return !allProperties; } @@ -71,15 +66,7 @@ public class SqlTreeProperties { this.readOnly = readOnly; } - public TableJoin[] getTableJoins() { - return tableJoins; - } - - public void setTableJoins(TableJoin[] tableJoins) { - this.tableJoins = tableJoins; - } - - public void setAllProperties() { + void setAllProperties() { this.allProperties = true; } @@ -89,13 +76,13 @@ public class SqlTreeProperties { * Return true if a Sql distinct is required. *

*/ - public boolean requireSqlDistinct(ManyWhereJoins manyWhereJoins) { + boolean requireSqlDistinct(ManyWhereJoins manyWhereJoins) { String joinProperty = aggregationJoin(); if (joinProperty != null) { aggregation = true; manyWhereJoins.addAggregationJoin(joinProperty); return false; - } else{ + } else { return manyWhereJoins.requireSqlDistinct(); } } @@ -120,4 +107,4 @@ public class SqlTreeProperties { } return null; } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 8ffb97800..9a32050f1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -1,7 +1,24 @@ package com.avaje.ebeaninternal.server.querydefn; -import com.avaje.ebean.*; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.Expression; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.FetchConfig; +import com.avaje.ebean.FetchPath; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.OrderBy; import com.avaje.ebean.OrderBy.Property; +import com.avaje.ebean.PagedList; +import com.avaje.ebean.PersistenceContextScope; +import com.avaje.ebean.Query; +import com.avaje.ebean.QueryEachConsumer; +import com.avaje.ebean.QueryEachWhileConsumer; +import com.avaje.ebean.QueryIterator; +import com.avaje.ebean.RawSql; +import com.avaje.ebean.Version; import com.avaje.ebean.bean.CallStack; import com.avaje.ebean.bean.ObjectGraphNode; import com.avaje.ebean.bean.ObjectGraphOrigin; @@ -41,7 +58,7 @@ import java.util.Set; */ public class DefaultOrmQuery implements SpiQuery { - public static final String DEFAULT_QUERY_NAME = "default"; + private static final String DEFAULT_QUERY_NAME = "default"; private static final FetchConfig FETCH_QUERY = new FetchConfig().query(); @@ -135,7 +152,7 @@ public class DefaultOrmQuery implements SpiQuery { */ private Object id; - private Map namedParams; + private Map namedParams; /** * Bind parameters when using the query language. @@ -276,7 +293,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public void addSoftDeletePredicate(String softDeletePredicate) { if (softDeletePredicates == null) { - softDeletePredicates = new ArrayList(); + softDeletePredicates = new ArrayList<>(); } softDeletePredicates.add(softDeletePredicate); } @@ -339,6 +356,15 @@ public class DefaultOrmQuery implements SpiQuery { return this; } + @Override + public String getOriginKey() { + if (parentNode == null || parentNode.getOriginQueryPoint() == null) { + return null; + } else { + return parentNode.getOriginQueryPoint().getKey(); + } + } + @Override public int getLazyLoadBatchSize() { return lazyLoadBatchSize; @@ -398,21 +424,19 @@ public class DefaultOrmQuery implements SpiQuery { return false; } - protected List removeQueryJoins() { + private List removeQueryJoins() { List queryJoins = detail.removeSecondaryQueries(); if (queryJoins != null) { if (orderBy != null) { // remove any orderBy properties that relate to // paths of the secondary queries - for (int i = 0; i < queryJoins.size(); i++) { - OrmQueryProperties joinPath = queryJoins.get(i); - + for (OrmQueryProperties joinPath : queryJoins) { // loop through the orderBy properties and // move any ones related to the query join List properties = orderBy.getProperties(); Iterator it = properties.iterator(); while (it.hasNext()) { - OrderBy.Property property = it.next(); + Property property = it.next(); if (property.getProperty().startsWith(joinPath.getPath())) { // remove this orderBy segment and // add it to the secondary join @@ -426,7 +450,7 @@ public class DefaultOrmQuery implements SpiQuery { return queryJoins; } - protected List removeLazyJoins() { + private List removeLazyJoins() { return detail.removeSecondaryLazyQueries(); } @@ -461,10 +485,6 @@ public class DefaultOrmQuery implements SpiQuery { return true; } - protected void setOrmQueryDetail(OrmQueryDetail detail) { - this.detail = detail; - } - @Override public void setDefaultSelectClause() { detail.setDefaultSelectClause(beanDescriptor); @@ -594,7 +614,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public DefaultOrmQuery copy(EbeanServer server) { - DefaultOrmQuery copy = new DefaultOrmQuery(beanDescriptor, server, expressionFactory); + DefaultOrmQuery copy = new DefaultOrmQuery<>(beanDescriptor, server, expressionFactory); copy.m2mIncludeJoin = m2mIncludeJoin; copy.profilingListener = profilingListener; @@ -824,7 +844,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public void logSecondaryQuery(SpiQuery query) { if (loggedSecondaryQueries == null) { - loggedSecondaryQueries = new ArrayList>(); + loggedSecondaryQueries = new ArrayList<>(); } loggedSecondaryQueries.add(query); } @@ -861,7 +881,7 @@ public class DefaultOrmQuery implements SpiQuery { */ private int calculateOriginQueryHash() { int hc = beanType.getName().hashCode(); - hc = hc * 31 + (type == null ? 0 : type.ordinal()); + hc = hc * 92821 + (type == null ? 0 : type.ordinal()); return hc; } @@ -871,9 +891,9 @@ public class DefaultOrmQuery implements SpiQuery { CQueryPlanKey createQueryPlanKey() { queryPlanKey = new OrmQueryPlanKey(m2mIncludeJoin, type, detail, maxRows, firstRow, - disableLazyLoading, orderBy, - distinct, sqlDistinct, mapKey, id, bindParams, whereExpressions, havingExpressions, - temporalMode, forUpdate, rootTableAlias, rawSql, updateProperties); + disableLazyLoading, orderBy, + distinct, sqlDistinct, mapKey, id, bindParams, whereExpressions, havingExpressions, + temporalMode, forUpdate, rootTableAlias, rawSql, updateProperties); return queryPlanKey; } @@ -911,12 +931,12 @@ public class DefaultOrmQuery implements SpiQuery { @Override public int queryBindHash() { int hc = (id == null ? 0 : id.hashCode()); - hc = hc * 31 + (whereExpressions == null ? 0 : whereExpressions.queryBindHash()); - hc = hc * 31 + (havingExpressions == null ? 0 : havingExpressions.queryBindHash()); - hc = hc * 31 + (bindParams == null ? 0 : bindParams.queryBindHash()); - hc = hc * 31 + (asOf == null ? 0 : asOf.hashCode()); - hc = hc * 31 + (versionsStart == null ? 0 : versionsStart.hashCode()); - hc = hc * 31 + (versionsEnd == null ? 0 : versionsEnd.hashCode()); + hc = hc * 92821 + (whereExpressions == null ? 0 : whereExpressions.queryBindHash()); + hc = hc * 92821 + (havingExpressions == null ? 0 : havingExpressions.queryBindHash()); + hc = hc * 92821 + (bindParams == null ? 0 : bindParams.queryBindHash()); + hc = hc * 92821 + (asOf == null ? 0 : asOf.hashCode()); + hc = hc * 92821 + (versionsStart == null ? 0 : versionsStart.hashCode()); + hc = hc * 92821 + (versionsEnd == null ? 0 : versionsEnd.hashCode()); return hc; } @@ -982,7 +1002,7 @@ public class DefaultOrmQuery implements SpiQuery { public boolean isExcludeBeanCache() { // not using L2 cache for asDraft() query - return excludeBeanCache || isAsDraft() ; + return excludeBeanCache || isAsDraft(); } @Override @@ -1084,7 +1104,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public List findIds() { + public List findIds() { // a copy of this query is made in the server // as the query needs to modified (so we modify // the copy rather than this query instance) @@ -1149,7 +1169,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override @SuppressWarnings("unchecked") public List findSingleAttributeList() { - return (List)server.findSingleAttributeList(this, null); + return (List) server.findSingleAttributeList(this, null); } @Override @@ -1225,7 +1245,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public OrderBy order() { if (orderBy == null) { - orderBy = new OrderBy(this, null); + orderBy = new OrderBy<>(this, null); } return orderBy; } @@ -1240,7 +1260,7 @@ public class DefaultOrmQuery implements SpiQuery { if (orderByClause == null || orderByClause.trim().isEmpty()) { this.orderBy = null; } else { - this.orderBy = new OrderBy(this, orderByClause); + this.orderBy = new OrderBy<>(this, orderByClause); } return this; } @@ -1384,7 +1404,7 @@ public class DefaultOrmQuery implements SpiQuery { public ExpressionList text() { if (textExpressions == null) { useDocStore = true; - textExpressions = new DefaultExpressionList(this); + textExpressions = new DefaultExpressionList<>(this); } return textExpressions; } @@ -1392,7 +1412,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public ExpressionList where() { if (whereExpressions == null) { - whereExpressions = new DefaultExpressionList(this, null); + whereExpressions = new DefaultExpressionList<>(this, null); } return whereExpressions; } @@ -1413,7 +1433,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public ExpressionList having() { if (havingExpressions == null) { - havingExpressions = new DefaultExpressionList(this, null); + havingExpressions = new DefaultExpressionList<>(this, null); } return havingExpressions; } @@ -1456,7 +1476,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public SpiNamedParam createNamedParameter(String name) { if (namedParams == null) { - namedParams = new HashMap(); + namedParams = new HashMap<>(); } ONamedParam param = namedParams.get(name); @@ -1577,7 +1597,7 @@ public class DefaultOrmQuery implements SpiQuery { return validation.getUnknownProperties(); } - public void setUpdateProperties(OrmUpdateProperties updateProperties) { + void setUpdateProperties(OrmUpdateProperties updateProperties) { this.updateProperties = updateProperties; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java index 8b0a65a51..3939c9a87 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.querydefn; -import java.io.Serializable; - import com.avaje.ebean.EbeanServer; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.SpiUpdate; +import java.io.Serializable; + /** * Default implementation of OrmUpdate. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java index 97eed9b0f..578adc703 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java @@ -7,7 +7,6 @@ import com.avaje.ebean.SqlRow; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.SpiSqlQuery; -import java.sql.PreparedStatement; import java.util.List; /** @@ -27,11 +26,6 @@ public class DefaultRelationalQuery implements SpiSqlQuery { private int timeout; - /** - * For the purposes of cancelling the query. - */ - private transient PreparedStatement pstmt; - private int bufferFetchSizeHint; /** @@ -128,10 +122,4 @@ public class DefaultRelationalQuery implements SpiSqlQuery { return query; } - public void setPreparedStatement(PreparedStatement pstmt) { - synchronized (this) { - this.pstmt = pstmt; - } - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java index 66975ab2d..261361da3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java @@ -7,7 +7,7 @@ import javax.persistence.PersistenceException; /** * Named parameter used as placeholder in expressions created by EQL language parsing. */ -public class ONamedParam implements SpiNamedParam { +class ONamedParam implements SpiNamedParam { private final String name; @@ -16,7 +16,7 @@ public class ONamedParam implements SpiNamedParam { /** * Create with the given name. */ - public ONamedParam(String name) { + ONamedParam(String name) { this.name = name; } @@ -37,9 +37,9 @@ public class ONamedParam implements SpiNamedParam { /** * Check the bind value has been set (so does not support null value). */ - public void checkValueSet() { + void checkValueSet() { if (value == null) { - throw new PersistenceException("Named parameter ["+name+"] has not had it's value set."); + throw new PersistenceException("Named parameter [" + name + "] has not had it's value set."); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java index dc284e24b..b9706d23a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java @@ -42,7 +42,7 @@ public class OrmQueryDetail implements Serializable { /** * Contains the fetch/lazy/query joins and their properties. */ - private LinkedHashMap fetchPaths = new LinkedHashMap(); + private LinkedHashMap fetchPaths = new LinkedHashMap<>(); /** * Return a deep copy of the OrmQueryDetail. @@ -168,7 +168,7 @@ public class OrmQueryDetail implements Serializable { baseProps = new OrmQueryProperties(null, columns, null); } - public boolean containsProperty(String property) { + boolean containsProperty(String property) { return baseProps.isIncluded(property); } @@ -179,17 +179,17 @@ public class OrmQueryDetail implements Serializable { this.baseProps = baseProps; } - public List removeSecondaryQueries() { + List removeSecondaryQueries() { return removeSecondaryQueries(false); } - public List removeSecondaryLazyQueries() { + List removeSecondaryLazyQueries() { return removeSecondaryQueries(true); } private List removeSecondaryQueries(boolean lazyQuery) { - ArrayList matchingPaths = new ArrayList(2); + ArrayList matchingPaths = new ArrayList<>(2); for (OrmQueryProperties chunk : fetchPaths.values()) { boolean match = lazyQuery ? chunk.isLazyFetch() : chunk.isQueryFetch(); @@ -206,10 +206,9 @@ public class OrmQueryDetail implements Serializable { Collections.sort(matchingPaths); // the list of secondary queries - ArrayList props = new ArrayList(); + ArrayList props = new ArrayList<>(); - for (int i = 0; i < matchingPaths.size(); i++) { - String path = matchingPaths.get(i); + for (String path : matchingPaths) { OrmQueryProperties secQuery = fetchPaths.remove(path); if (secQuery != null) { props.add(secQuery); @@ -231,8 +230,8 @@ public class OrmQueryDetail implements Serializable { // Add the secondary queries as select properties // to the parent chunk to ensure the foreign keys // are included in the query - for (int i = 0; i < props.size(); i++) { - String path = props.get(i).getPath(); + for (OrmQueryProperties prop : props) { + String path = prop.getPath(); // split into parent and property String[] split = SplitName.split(path); // add property to parent chunk @@ -243,7 +242,7 @@ public class OrmQueryDetail implements Serializable { return props; } - public boolean tuneFetchProperties(OrmQueryDetail tunedDetail) { + boolean tuneFetchProperties(OrmQueryDetail tunedDetail) { boolean tuned = false; @@ -304,7 +303,7 @@ public class OrmQueryDetail implements Serializable { public void sortFetchPaths(BeanDescriptor d) { if (!fetchPaths.isEmpty()) { - LinkedHashMap sorted = new LinkedHashMap(); + LinkedHashMap sorted = new LinkedHashMap<>(); for (OrmQueryProperties p : fetchPaths.values()) { sortFetchPaths(d, p, sorted); } @@ -341,7 +340,7 @@ public class OrmQueryDetail implements Serializable { /** * Mark 'fetch joins' to 'many' properties over to 'query joins' where needed. */ - public void markQueryJoins(BeanDescriptor beanDescriptor, String lazyLoadManyPath, boolean allowOne) { + void markQueryJoins(BeanDescriptor beanDescriptor, String lazyLoadManyPath, boolean allowOne) { // the name of the many fetch property if there is one String manyFetchProperty = null; @@ -380,8 +379,8 @@ public class OrmQueryDetail implements Serializable { */ private boolean isQueryJoinCandidate(String lazyLoadManyPath, OrmQueryProperties chunk) { return chunk.isFetchJoin() - && !isLazyLoadManyRoot(lazyLoadManyPath, chunk) - && !hasParentSecJoin(lazyLoadManyPath, chunk); + && !isLazyLoadManyRoot(lazyLoadManyPath, chunk) + && !hasParentSecJoin(lazyLoadManyPath, chunk); } /** @@ -439,7 +438,7 @@ public class OrmQueryDetail implements Serializable { } } - public boolean hasSelectClause() { + private boolean hasSelectClause() { return baseProps.hasSelectClause(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java index 83e0c04b4..5fa81c4d8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java @@ -13,14 +13,6 @@ public class OrmQueryDetailParser { private final OrmQueryDetail detail = new OrmQueryDetail(); - private int maxRows; - - private int firstRow; - - private String rawWhereClause; - - private String rawOrderBy; - private final SimpleTextParser parser; public OrmQueryDetailParser(String oql) { @@ -57,91 +49,9 @@ public class OrmQueryDetailParser { private void process() { if (isFetch()) { detail.fetch(readFindFetch()); - - } else if (parser.isMatch("where")) { - readWhere(); - - } else if (parser.isMatch("order", "by")) { - readOrderBy(); - - } else if (parser.isMatch("limit")) { - readLimit(); - } else { throw new PersistenceException("Query expected 'fetch', 'where','order by' or 'limit' keyword but got [" - + parser.getWord() + "] \r " + parser.getOql()); - } - } - - private void readLimit() { - try { - String maxLimit = parser.nextWord(); - maxRows = Integer.parseInt(maxLimit); - - String offsetKeyword = parser.nextWord(); - if (offsetKeyword != null) { - if (!parser.isMatch("offset")) { - throw new PersistenceException("expected offset keyword but got " + parser.getWord()); - } - String firstRowLimit = parser.nextWord(); - firstRow = Integer.parseInt(firstRowLimit); - parser.nextWord(); - } - } catch (NumberFormatException e) { - String msg = "Expected an integer for maxRows or firstRows in limit offset clause"; - throw new PersistenceException(msg, e); - } - } - - private void readOrderBy() { - // read the by - parser.nextWord(); - - StringBuilder sb = new StringBuilder(); - while (parser.nextWord() != null) { - if (parser.isMatch("limit")) { - break; - } else { - String w = parser.getWord(); - if (!w.startsWith("(")) { - sb.append(" "); - } - sb.append(w); - } - } - rawOrderBy = sb.toString().trim(); - - if (!parser.isFinished()) { - readLimit(); - } - } - - private void readWhere() { - - int nextMode = 0; - StringBuilder sb = new StringBuilder(); - while ((parser.nextWord()) != null) { - if (parser.isMatch("order", "by")) { - nextMode = 1; - break; - - } else if (parser.isMatch("limit")) { - nextMode = 2; - break; - - } else { - sb.append(" ").append(parser.getWord()); - } - } - String whereClause = sb.toString().trim(); - if (!whereClause.isEmpty()) { - rawWhereClause = whereClause; - } - - if (nextMode == 1) { - readOrderBy(); - } else if (nextMode == 2) { - readLimit(); + + parser.getWord() + "] \r " + parser.getOql()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java index 60b15fe5d..10e2fae98 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java @@ -12,7 +12,7 @@ import com.avaje.ebeaninternal.server.deploy.TableJoin; /** * Query plan key for ORM queries. */ -public class OrmQueryPlanKey implements CQueryPlanKey { +class OrmQueryPlanKey implements CQueryPlanKey { private final String m2mIncludeTable; private final String orderByAsSting; @@ -35,7 +35,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey { private final int planHash; private final int bindCount; - public OrmQueryPlanKey(TableJoin m2mIncludeTable, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, OrderBy orderBy, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) { + OrmQueryPlanKey(TableJoin m2mIncludeTable, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, OrderBy orderBy, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) { this.m2mIncludeTable = m2mIncludeTable == null ? null : m2mIncludeTable.getTable(); this.type = type; @@ -118,11 +118,14 @@ public class OrmQueryPlanKey implements CQueryPlanKey { if (hasIdValue != that.hasIdValue) return false; if (type != that.type) return false; if (temporalMode != that.temporalMode) return false; - if (m2mIncludeTable != null ? !m2mIncludeTable.equals(that.m2mIncludeTable) : that.m2mIncludeTable != null) return false; - if (orderByAsSting != null ? !orderByAsSting.equals(that.orderByAsSting) : that.orderByAsSting != null) return false; + if (m2mIncludeTable != null ? !m2mIncludeTable.equals(that.m2mIncludeTable) : that.m2mIncludeTable != null) + return false; + if (orderByAsSting != null ? !orderByAsSting.equals(that.orderByAsSting) : that.orderByAsSting != null) + return false; if (where != null ? !where.isSameByPlan(that.where) : that.where != null) return false; if (having != null ? !having.isSameByPlan(that.having) : that.having != null) return false; - if (updateProperties != null ? !updateProperties.isSameByPlan(that.updateProperties) : that.updateProperties != null) return false; + if (updateProperties != null ? !updateProperties.isSameByPlan(that.updateProperties) : that.updateProperties != null) + return false; if (rawSqlKey != null ? !rawSqlKey.equals(that.rawSqlKey) : that.rawSqlKey != null) return false; if (mapKey != null ? !mapKey.equals(that.mapKey) : that.mapKey != null) return false; return rootTableAlias != null ? rootTableAlias.equals(that.rootTableAlias) : that.rootTableAlias == null; diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java index 838dc8f4d..c22b06e34 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -28,7 +28,7 @@ public class OrmQueryProperties implements Serializable { private static final long serialVersionUID = -8785582703966455658L; - protected static final FetchConfig DEFAULT_FETCH = new FetchConfig(); + static final FetchConfig DEFAULT_FETCH = new FetchConfig(); private final String parentPath; private final String path; @@ -77,7 +77,7 @@ public class OrmQueryProperties implements Serializable { * Construct for root so path (and parentPath) are null. */ public OrmQueryProperties() { - this((String)null); + this((String) null); } /** @@ -123,7 +123,7 @@ public class OrmQueryProperties implements Serializable { this.parentPath = SplitName.parent(path); // for rawSql parsedProperties can be empty (when only fetching Id property) this.included = parsedProperties; - this.rawProperties = join(parsedProperties); + this.rawProperties = join(parsedProperties); this.trimmedProperties = rawProperties; this.cache = false; this.readOnly = false; @@ -160,9 +160,9 @@ public class OrmQueryProperties implements Serializable { this.readOnly = source.readOnly; this.fetchConfig = source.fetchConfig; this.filterMany = source.filterMany; - this.included = (source.included == null) ? null : new LinkedHashSet(source.included); + this.included = (source.included == null) ? null : new LinkedHashSet<>(source.included); if (includedBeanJoin != null) { - this.includedBeanJoin = new HashSet(source.includedBeanJoin); + this.includedBeanJoin = new HashSet<>(source.includedBeanJoin); } } @@ -177,7 +177,7 @@ public class OrmQueryProperties implements Serializable { * Move a OrderBy.Property from the main query to this query join. */ @SuppressWarnings("rawtypes") - public void addSecJoinOrderProperty(OrderBy.Property orderProp) { + void addSecJoinOrderProperty(OrderBy.Property orderProp) { if (orderBy == null) { orderBy = new OrderBy(); } @@ -208,7 +208,7 @@ public class OrmQueryProperties implements Serializable { /** * Return the filterMany expression list (can be null). */ - public SpiExpressionList getFilterManyTrimPath(int trimPath) { + private SpiExpressionList getFilterManyTrimPath(int trimPath) { if (filterMany == null) { return null; } @@ -250,8 +250,7 @@ public class OrmQueryProperties implements Serializable { if (secondaryChildren != null) { int trimPath = path.length() + 1; - for (int i = 0; i < secondaryChildren.size(); i++) { - OrmQueryProperties p = secondaryChildren.get(i); + for (OrmQueryProperties p : secondaryChildren) { String path = p.getPath(); path = path.substring(trimPath); query.fetch(path, p.getProperties(), p.getFetchConfig()); @@ -297,7 +296,7 @@ public class OrmQueryProperties implements Serializable { return sb.toString(); } - public boolean isChild(OrmQueryProperties possibleChild) { + boolean isChild(OrmQueryProperties possibleChild) { return possibleChild.getPath().startsWith(path + "."); } @@ -306,7 +305,7 @@ public class OrmQueryProperties implements Serializable { */ public void add(OrmQueryProperties child) { if (secondaryChildren == null) { - secondaryChildren = new ArrayList(); + secondaryChildren = new ArrayList<>(); } secondaryChildren.add(child); } @@ -339,9 +338,9 @@ public class OrmQueryProperties implements Serializable { /** * Add a bean join property. */ - public void includeBeanJoin(String propertyName) { + void includeBeanJoin(String propertyName) { if (includedBeanJoin == null) { - includedBeanJoin = new HashSet(); + includedBeanJoin = new HashSet<>(); } includedBeanJoin.add(propertyName); } @@ -358,15 +357,15 @@ public class OrmQueryProperties implements Serializable { return included; } - LinkedHashSet temp = new LinkedHashSet(2 * (secondaryQueryJoins.size() + included.size())); + LinkedHashSet temp = new LinkedHashSet<>(2 * (secondaryQueryJoins.size() + included.size())); temp.addAll(included); temp.addAll(secondaryQueryJoins); return temp; } - public void addSecondaryQueryJoin(String property) { + void addSecondaryQueryJoin(String property) { if (secondaryQueryJoins == null) { - secondaryQueryJoins = new HashSet(4); + secondaryQueryJoins = new HashSet<>(4); } secondaryQueryJoins.add(property); } @@ -378,7 +377,7 @@ public class OrmQueryProperties implements Serializable { return included; } - public boolean isIncluded(String propName) { + boolean isIncluded(String propName) { if (includedBeanJoin != null && includedBeanJoin.contains(propName)) { return false; @@ -390,7 +389,7 @@ public class OrmQueryProperties implements Serializable { /** * Mark this path as needing to be a query join. */ - public void markForQueryJoin() { + void markForQueryJoin() { markForQueryJoin = true; } @@ -404,14 +403,14 @@ public class OrmQueryProperties implements Serializable { /** * Return true if this path is a 'fetch join'. */ - public boolean isFetchJoin() { + boolean isFetchJoin() { return !isQueryFetch() && !isLazyFetch(); } /** * Return true if this path is a lazy fetch. */ - public boolean isLazyFetch() { + boolean isLazyFetch() { return getLazyFetchBatch() > -1; } @@ -453,7 +452,7 @@ public class OrmQueryProperties implements Serializable { /** * Return the parent path. */ - public String getParentPath() { + String getParentPath() { return parentPath; } @@ -467,7 +466,7 @@ public class OrmQueryProperties implements Serializable { /** * Return true if the properties are the same for autoTune purposes. */ - public boolean isSameByAutoTune(OrmQueryProperties p2) { + boolean isSameByAutoTune(OrmQueryProperties p2) { if (included == null) { return p2 == null || p2.included == null; } else if (p2 == null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java index eeeacc39c..31eb2555a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java @@ -8,14 +8,14 @@ import java.util.LinkedHashSet; /** * Parses the path properties string. */ -public class OrmQueryPropertiesParser { +class OrmQueryPropertiesParser { private static Response EMPTY = new Response(); /** * Immutable response of the parsed properties and options. */ - public static class Response { + static class Response { final boolean readOnly; final boolean cache; @@ -23,7 +23,7 @@ public class OrmQueryPropertiesParser { final String properties; final LinkedHashSet included; - public Response(boolean readOnly, boolean cache, int queryFetchBatch, int lazyFetchBatch, String properties, LinkedHashSet included) { + Response(boolean readOnly, boolean cache, int queryFetchBatch, int lazyFetchBatch, String properties, LinkedHashSet included) { this.readOnly = readOnly; this.cache = cache; this.properties = properties; @@ -35,7 +35,7 @@ public class OrmQueryPropertiesParser { } } - public Response() { + Response() { this.readOnly = false; this.cache = false; this.fetchConfig = OrmQueryProperties.DEFAULT_FETCH; @@ -61,7 +61,7 @@ public class OrmQueryPropertiesParser { private int queryFetchBatch = -1; private int lazyFetchBatch = -1; - private OrmQueryPropertiesParser(String inputProperties) { + private OrmQueryPropertiesParser(String inputProperties) { this.inputProperties = inputProperties; } @@ -116,12 +116,12 @@ public class OrmQueryPropertiesParser { String[] res = inputProperties.split(","); StringBuilder sb = new StringBuilder(70); - LinkedHashSet propertySet = new LinkedHashSet(res.length * 2); + LinkedHashSet propertySet = new LinkedHashSet<>(res.length * 2); int count = 0; String temp; - for (int i = 0; i < res.length; i++) { - temp = res[i].trim(); + for (String re : res) { + temp = re.trim(); if (!temp.isEmpty()) { if (count > 0) { sb.append(","); @@ -148,7 +148,7 @@ public class OrmQueryPropertiesParser { return propertySet; } - private int parseBatchHint( int pos, String option) { + private int parseBatchHint(int pos, String option) { int startPos = pos + option.length(); int endPos = findEndPos(startPos, inputProperties); diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQuerySecondary.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQuerySecondary.java index 85abbb7bc..f423d05bd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQuerySecondary.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQuerySecondary.java @@ -7,7 +7,7 @@ import java.util.List; /** * The secondary query paths for 'query joins' and 'lazy loading'. */ -public class OrmQuerySecondary implements SpiQuerySecondary { +class OrmQuerySecondary implements SpiQuerySecondary { private final List queryJoins; @@ -16,7 +16,7 @@ public class OrmQuerySecondary implements SpiQuerySecondary { /** * Construct with the 'query join' and 'lazy join' path properties. */ - public OrmQuerySecondary(List queryJoins, List lazyJoins) { + OrmQuerySecondary(List queryJoins, List lazyJoins) { this.queryJoins = queryJoins; this.lazyJoins = lazyJoins; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java index d3ed01562..08ff01d7f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java @@ -41,7 +41,7 @@ public class OrmUpdateProperties { /** * Set property to null. */ - static class NullValue extends Value { + private static class NullValue extends Value { @Override public String bindClause() { return "=null"; @@ -51,7 +51,7 @@ public class OrmUpdateProperties { /** * Set property to a simple value. */ - static class SimpleValue extends Value { + private static class SimpleValue extends Value { final Object value; @@ -79,7 +79,7 @@ public class OrmUpdateProperties { /** * Set using an expression with no bind value. */ - static class NoneValue extends Value { + private static class NoneValue extends Value { @Override public String bindClause() { return ""; @@ -89,11 +89,11 @@ public class OrmUpdateProperties { /** * Set using an expression with many bind values. */ - static class RawArrayValue extends Value { + private static class RawArrayValue extends Value { final Object[] bindValues; - public RawArrayValue(Object[] bindValues) { + RawArrayValue(Object[] bindValues) { this.bindValues = bindValues; } @@ -114,7 +114,7 @@ public class OrmUpdateProperties { /** * The set properties/expressions and their bind values. */ - private LinkedHashMap values = new LinkedHashMap(); + private LinkedHashMap values = new LinkedHashMap<>(); /** * Normal set property. @@ -138,7 +138,7 @@ public class OrmUpdateProperties { /** * Set a raw expression with many bind values. */ - public void setRaw(String propertyExpression, Object... vals) { + void setRaw(String propertyExpression, Object... vals) { if (vals.length == 0) { setRaw(propertyExpression); } else { @@ -151,13 +151,13 @@ public class OrmUpdateProperties { */ public boolean isSameByPlan(OrmUpdateProperties that) { return that.values.size() == values.size() - && logicalSetClause().equals(that.logicalSetClause()); + && logicalSetClause().equals(that.logicalSetClause()); } /** * Build the hash for the query plan caching. */ - public void buildQueryPlanHash(HashQueryPlanBuilder builder) { + void buildQueryPlanHash(HashQueryPlanBuilder builder) { builder.add(OrmUpdateProperties.class); Set> entries = values.entrySet(); for (Map.Entry entry : entries) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java index 345503966..cfae419ca 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java @@ -24,7 +24,7 @@ public class SimpleTextParser { return pos; } - public String getOql() { + String getOql() { return oql; } @@ -32,7 +32,7 @@ public class SimpleTextParser { return word; } - public String peekNextWord() { + private String peekNextWord() { int origPos = pos; String nw = nextWordInternal(); pos = origPos; diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java index 650c94f5e..161df976e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java @@ -4,19 +4,19 @@ package com.avaje.ebeaninternal.server.text.csv; // rbygrave: Made some Java Generics tweaks to remove warnings /** - Copyright 2005 Bytecode Pty Ltd. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * Copyright 2005 Bytecode Pty Ltd. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import java.io.BufferedReader; @@ -27,223 +27,222 @@ import java.util.List; /** * Glen Smith's CSV reader released under Apache License version 2. - * + * * @author Glen Smith - * + * */ public class CsvUtilReader { - private final BufferedReader br; + private final BufferedReader br; - private boolean hasNext = true; + private boolean hasNext = true; - private final char separator; + private final char separator; - private final char quotechar; - - private final int skipLines; + private final char quotechar; - private boolean linesSkiped; + private final int skipLines; - /** The default separator to use if none is supplied to the constructor. */ - public static final char DEFAULT_SEPARATOR = ','; + private boolean linesSkiped; - /** - * The default quote character to use if none is supplied to the - * constructor. - */ - public static final char DEFAULT_QUOTE_CHARACTER = '"'; - - /** - * The default line to start reading. - */ - public static final int DEFAULT_SKIP_LINES = 0; + /** The default separator to use if none is supplied to the constructor. */ + public static final char DEFAULT_SEPARATOR = ','; - /** - * Constructs CSVReader using a comma for the separator. - * - * @param reader - * the reader to an underlying CSV source. - */ - public CsvUtilReader(Reader reader) { - this(reader, DEFAULT_SEPARATOR); + /** + * The default quote character to use if none is supplied to the + * constructor. + */ + public static final char DEFAULT_QUOTE_CHARACTER = '"'; + + /** + * The default line to start reading. + */ + public static final int DEFAULT_SKIP_LINES = 0; + + /** + * Constructs CSVReader using a comma for the separator. + * + * @param reader + * the reader to an underlying CSV source. + */ + public CsvUtilReader(Reader reader) { + this(reader, DEFAULT_SEPARATOR); + } + + /** + * Constructs CSVReader with supplied separator. + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries. + */ + public CsvUtilReader(Reader reader, char separator) { + this(reader, separator, DEFAULT_QUOTE_CHARACTER); + } + + + /** + * Constructs CSVReader with supplied separator and quote char. + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + */ + public CsvUtilReader(Reader reader, char separator, char quotechar) { + this(reader, separator, quotechar, DEFAULT_SKIP_LINES); + } + + /** + * Constructs CSVReader with supplied separator and quote char. + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param line + * the line number to skip for start reading + */ + public CsvUtilReader(Reader reader, char separator, char quotechar, int line) { + this.br = new BufferedReader(reader); + this.separator = separator; + this.quotechar = quotechar; + this.skipLines = line; + } + + /** + * Reads the entire file into a List with each element being a String[] of + * tokens. + * + * @return a List of String[], with each String[] representing a line of the + * file. + * + * @throws IOException + * if bad things happen during the read + */ + public List readAll() throws IOException { + + List allElements = new ArrayList<>(); + while (hasNext) { + String[] nextLineAsTokens = readNext(); + if (nextLineAsTokens != null) + allElements.add(nextLineAsTokens); + } + return allElements; + + } + + /** + * Reads the next line from the buffer and converts to a string array. + * + * @return a string array with each comma-separated element as a separate + * entry. + * + * @throws IOException + * if bad things happen during the read + */ + public String[] readNext() throws IOException { + + String nextLine = getNextLine(); + return hasNext ? parseLine(nextLine) : null; + } + + /** + * Reads the next line from the file. + * + * @return the next line from the file without trailing newline + * @throws IOException + * if bad things happen during the read + */ + private String getNextLine() throws IOException { + if (!this.linesSkiped) { + for (int i = 0; i < skipLines; i++) { + br.readLine(); + } + this.linesSkiped = true; + } + String nextLine = br.readLine(); + if (nextLine == null) { + hasNext = false; + } + return hasNext ? nextLine : null; + } + + /** + * Parses an incoming String and returns an array of elements. + * + * @param nextLine + * the string to parse + * @return the comma-tokenized list of elements, or null if nextLine is null + * @throws IOException if bad things happen during the read + */ + private String[] parseLine(String nextLine) throws IOException { + + if (nextLine == null) { + return null; } - /** - * Constructs CSVReader with supplied separator. - * - * @param reader - * the reader to an underlying CSV source. - * @param separator - * the delimiter to use for separating entries. - */ - public CsvUtilReader(Reader reader, char separator) { - this(reader, separator, DEFAULT_QUOTE_CHARACTER); - } - - + List tokensOnThisLine = new ArrayList<>(); - /** - * Constructs CSVReader with supplied separator and quote char. - * - * @param reader - * the reader to an underlying CSV source. - * @param separator - * the delimiter to use for separating entries - * @param quotechar - * the character to use for quoted elements - */ - public CsvUtilReader(Reader reader, char separator, char quotechar) { - this(reader, separator, quotechar, DEFAULT_SKIP_LINES); - } - - /** - * Constructs CSVReader with supplied separator and quote char. - * - * @param reader - * the reader to an underlying CSV source. - * @param separator - * the delimiter to use for separating entries - * @param quotechar - * the character to use for quoted elements - * @param line - * the line number to skip for start reading - */ - public CsvUtilReader(Reader reader, char separator, char quotechar, int line) { - this.br = new BufferedReader(reader); - this.separator = separator; - this.quotechar = quotechar; - this.skipLines = line; - } + StringBuilder sb = new StringBuilder(); + boolean inQuotes = false; + do { + if (inQuotes) { + // continuing a quoted section, reappend newline + sb.append("\n"); + nextLine = getNextLine(); + if (nextLine == null) + break; + } + for (int i = 0; i < nextLine.length(); i++) { - /** - * Reads the entire file into a List with each element being a String[] of - * tokens. - * - * @return a List of String[], with each String[] representing a line of the - * file. - * - * @throws IOException - * if bad things happen during the read - */ - public List readAll() throws IOException { - - List allElements = new ArrayList(); - while (hasNext) { - String[] nextLineAsTokens = readNext(); - if (nextLineAsTokens != null) - allElements.add(nextLineAsTokens); - } - return allElements; - - } - - /** - * Reads the next line from the buffer and converts to a string array. - * - * @return a string array with each comma-separated element as a separate - * entry. - * - * @throws IOException - * if bad things happen during the read - */ - public String[] readNext() throws IOException { - - String nextLine = getNextLine(); - return hasNext ? parseLine(nextLine) : null; - } - - /** - * Reads the next line from the file. - * - * @return the next line from the file without trailing newline - * @throws IOException - * if bad things happen during the read - */ - private String getNextLine() throws IOException { - if (!this.linesSkiped) { - for (int i = 0; i < skipLines; i++) { - br.readLine(); + char c = nextLine.charAt(i); + if (c == quotechar) { + // this gets complex... the quote may end a quoted block, or escape another quote. + // do a 1-char lookahead: + if (inQuotes // we are in quotes, therefore there can be escaped quotes in here. + && nextLine.length() > (i + 1) // there is indeed another character to check. + && nextLine.charAt(i + 1) == quotechar) { // ..and that char. is a quote also. + // we have two quote chars in a row == one quote char, so consume them both and + // put one on the token. we do *not* exit the quoted text. + sb.append(nextLine.charAt(i + 1)); + i++; + } else { + inQuotes = !inQuotes; + // the tricky case of an embedded quote in the middle: a,bc"d"ef,g + if (i > 2 //not on the begining of the line + && nextLine.charAt(i - 1) != this.separator //not at the begining of an escape sequence + && nextLine.length() > (i + 1) && + nextLine.charAt(i + 1) != this.separator //not at the end of an escape sequence + ) { + sb.append(c); } - this.linesSkiped = true; + } + } else if (c == separator && !inQuotes) { + tokensOnThisLine.add(sb.toString().trim()); + sb = new StringBuilder(); // start work on next token + } else { + sb.append(c); } - String nextLine = br.readLine(); - if (nextLine == null) { - hasNext = false; - } - return hasNext ? nextLine : null; - } + } + } while (inQuotes); + tokensOnThisLine.add(sb.toString().trim()); + return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]); + } - /** - * Parses an incoming String and returns an array of elements. - * - * @param nextLine - * the string to parse - * @return the comma-tokenized list of elements, or null if nextLine is null - * @throws IOException if bad things happen during the read - */ - private String[] parseLine(String nextLine) throws IOException { + /** + * Closes the underlying reader. + * + * @throws IOException if the close fails + */ + public void close() throws IOException { + br.close(); + } - if (nextLine == null) { - return null; - } - - List tokensOnThisLine = new ArrayList(); - - StringBuilder sb = new StringBuilder(); - boolean inQuotes = false; - do { - if (inQuotes) { - // continuing a quoted section, reappend newline - sb.append("\n"); - nextLine = getNextLine(); - if (nextLine == null) - break; - } - for (int i = 0; i < nextLine.length(); i++) { - - char c = nextLine.charAt(i); - if (c == quotechar) { - // this gets complex... the quote may end a quoted block, or escape another quote. - // do a 1-char lookahead: - if( inQuotes // we are in quotes, therefore there can be escaped quotes in here. - && nextLine.length() > (i+1) // there is indeed another character to check. - && nextLine.charAt(i+1) == quotechar ){ // ..and that char. is a quote also. - // we have two quote chars in a row == one quote char, so consume them both and - // put one on the token. we do *not* exit the quoted text. - sb.append(nextLine.charAt(i+1)); - i++; - }else{ - inQuotes = !inQuotes; - // the tricky case of an embedded quote in the middle: a,bc"d"ef,g - if(i>2 //not on the begining of the line - && nextLine.charAt(i-1) != this.separator //not at the begining of an escape sequence - && nextLine.length()>(i+1) && - nextLine.charAt(i+1) != this.separator //not at the end of an escape sequence - ){ - sb.append(c); - } - } - } else if (c == separator && !inQuotes) { - tokensOnThisLine.add(sb.toString().trim()); - sb = new StringBuilder(); // start work on next token - } else { - sb.append(c); - } - } - } while (inQuotes); - tokensOnThisLine.add(sb.toString().trim()); - return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]); - } - - /** - * Closes the underlying reader. - * - * @throws IOException if the close fails - */ - public void close() throws IOException{ - br.close(); - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java index e185d3fe4..fffcff5b6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java @@ -1,16 +1,5 @@ package com.avaje.ebeaninternal.server.text.csv; -import java.io.Reader; -import java.sql.Types; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Locale; - import com.avaje.ebean.EbeanServer; import com.avaje.ebean.bean.EntityBean; import com.avaje.ebean.plugin.ExpressionPath; @@ -24,320 +13,331 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.el.ElPropertyValue; +import java.io.Reader; +import java.sql.Types; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Locale; + /** * Implementation of the CsvReader */ public class TCsvReader implements CsvReader { - private static final TimeStringParser TIME_PARSER = new TimeStringParser(); + private static final TimeStringParser TIME_PARSER = new TimeStringParser(); - private final EbeanServer server; + private final EbeanServer server; - private final BeanDescriptor descriptor; + private final BeanDescriptor descriptor; - private final List columnList = new ArrayList(); + private final List columnList = new ArrayList<>(); - private final CsvColumn ignoreColumn = new CsvColumn(); + private final CsvColumn ignoreColumn = new CsvColumn(); - private boolean hasHeader; + private boolean hasHeader; - private int logInfoFrequency = 1000; + private int logInfoFrequency = 1000; - private String defaultTimeFormat = "HH:mm:ss"; - private String defaultDateFormat = "yyyy-MM-dd"; - private String defaultTimestampFormat = "yyyy-MM-dd hh:mm:ss.fffffffff"; - private Locale defaultLocale = Locale.getDefault(); + private String defaultTimeFormat = "HH:mm:ss"; + private String defaultDateFormat = "yyyy-MM-dd"; + private String defaultTimestampFormat = "yyyy-MM-dd hh:mm:ss.fffffffff"; + private Locale defaultLocale = Locale.getDefault(); - /** - * The batch size used for JDBC statement batching. - */ - protected int persistBatchSize = 30; + /** + * The batch size used for JDBC statement batching. + */ + protected int persistBatchSize = 30; - private boolean addPropertiesFromHeader; + private boolean addPropertiesFromHeader; - public TCsvReader(EbeanServer server, BeanDescriptor descriptor) { - this.server = server; - this.descriptor = descriptor; - } + public TCsvReader(EbeanServer server, BeanDescriptor descriptor) { + this.server = server; + this.descriptor = descriptor; + } - public void setDefaultLocale(Locale defaultLocale) { - this.defaultLocale = defaultLocale; - } + public void setDefaultLocale(Locale defaultLocale) { + this.defaultLocale = defaultLocale; + } - public void setDefaultTimeFormat(String defaultTimeFormat) { - this.defaultTimeFormat = defaultTimeFormat; - } + public void setDefaultTimeFormat(String defaultTimeFormat) { + this.defaultTimeFormat = defaultTimeFormat; + } - public void setDefaultDateFormat(String defaultDateFormat) { - this.defaultDateFormat = defaultDateFormat; - } + public void setDefaultDateFormat(String defaultDateFormat) { + this.defaultDateFormat = defaultDateFormat; + } - public void setDefaultTimestampFormat(String defaultTimestampFormat) { - this.defaultTimestampFormat = defaultTimestampFormat; - } + public void setDefaultTimestampFormat(String defaultTimestampFormat) { + this.defaultTimestampFormat = defaultTimestampFormat; + } - public void setPersistBatchSize(int persistBatchSize) { - this.persistBatchSize = persistBatchSize; - } + public void setPersistBatchSize(int persistBatchSize) { + this.persistBatchSize = persistBatchSize; + } - public void setIgnoreHeader() { - setHasHeader(true, false); - } + public void setIgnoreHeader() { + setHasHeader(true, false); + } - public void setAddPropertiesFromHeader() { - setHasHeader(true, true); - } + public void setAddPropertiesFromHeader() { + setHasHeader(true, true); + } - public void setHasHeader(boolean hasHeader, boolean addPropertiesFromHeader) { - this.hasHeader = hasHeader; - this.addPropertiesFromHeader = addPropertiesFromHeader; - } + public void setHasHeader(boolean hasHeader, boolean addPropertiesFromHeader) { + this.hasHeader = hasHeader; + this.addPropertiesFromHeader = addPropertiesFromHeader; + } - public void setLogInfoFrequency(int logInfoFrequency) { - this.logInfoFrequency = logInfoFrequency; - } + public void setLogInfoFrequency(int logInfoFrequency) { + this.logInfoFrequency = logInfoFrequency; + } - public void addIgnore() { - columnList.add(ignoreColumn); - } + public void addIgnore() { + columnList.add(ignoreColumn); + } - public void addProperty(String propertyName) { - addProperty(propertyName, null); - } + public void addProperty(String propertyName) { + addProperty(propertyName, null); + } - public void addDateTime(String propertyName, String dateTimeFormat) { - addDateTime(propertyName, dateTimeFormat, Locale.getDefault()); - } + public void addDateTime(String propertyName, String dateTimeFormat) { + addDateTime(propertyName, dateTimeFormat, Locale.getDefault()); + } - public void addDateTime(String propertyName, String dateTimeFormat, Locale locale) { + public void addDateTime(String propertyName, String dateTimeFormat, Locale locale) { - ExpressionPath elProp = descriptor.getExpressionPath(propertyName); - if (!elProp.isDateTimeCapable()) { - throw new TextException("Property " + propertyName + " is not DateTime capable"); - } - if (dateTimeFormat == null) { - dateTimeFormat = getDefaultDateTimeFormat(elProp.getJdbcType()); - } + ExpressionPath elProp = descriptor.getExpressionPath(propertyName); + if (!elProp.isDateTimeCapable()) { + throw new TextException("Property " + propertyName + " is not DateTime capable"); + } + if (dateTimeFormat == null) { + dateTimeFormat = getDefaultDateTimeFormat(elProp.getJdbcType()); + } - if (locale == null) { - locale = defaultLocale; - } + if (locale == null) { + locale = defaultLocale; + } - SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat, locale); - DateTimeParser parser = new DateTimeParser(sdf, dateTimeFormat, elProp); + SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat, locale); + DateTimeParser parser = new DateTimeParser(sdf, dateTimeFormat, elProp); - CsvColumn column = new CsvColumn(elProp, parser); - columnList.add(column); - } + CsvColumn column = new CsvColumn(elProp, parser); + columnList.add(column); + } - private String getDefaultDateTimeFormat(int jdbcType) { - switch (jdbcType) { - case Types.TIME: - return defaultTimeFormat; - case Types.DATE: - return defaultDateFormat; - case Types.TIMESTAMP: - return defaultTimestampFormat; + private String getDefaultDateTimeFormat(int jdbcType) { + switch (jdbcType) { + case Types.TIME: + return defaultTimeFormat; + case Types.DATE: + return defaultDateFormat; + case Types.TIMESTAMP: + return defaultTimestampFormat; - default: - throw new RuntimeException("Expected java.sql.Types TIME,DATE or TIMESTAMP but got [" + jdbcType + "]"); - } - } + default: + throw new RuntimeException("Expected java.sql.Types TIME,DATE or TIMESTAMP but got [" + jdbcType + "]"); + } + } - public void addProperty(String propertyName, StringParser parser) { + public void addProperty(String propertyName, StringParser parser) { - ExpressionPath elProp = descriptor.getExpressionPath(propertyName); - if (parser == null) { - parser = elProp.getStringParser(); - } - CsvColumn column = new CsvColumn(elProp, parser); - columnList.add(column); - } + ExpressionPath elProp = descriptor.getExpressionPath(propertyName); + if (parser == null) { + parser = elProp.getStringParser(); + } + CsvColumn column = new CsvColumn(elProp, parser); + columnList.add(column); + } - public void process(Reader reader) throws Exception { - DefaultCsvCallback callback = new DefaultCsvCallback(persistBatchSize, logInfoFrequency); - process(reader, callback); - } + public void process(Reader reader) throws Exception { + DefaultCsvCallback callback = new DefaultCsvCallback<>(persistBatchSize, logInfoFrequency); + process(reader, callback); + } - public void process(Reader reader, CsvCallback callback) throws Exception { + public void process(Reader reader, CsvCallback callback) throws Exception { - if (reader == null) { - throw new NullPointerException("reader is null?"); - } - if (callback == null) { - throw new NullPointerException("callback is null?"); - } + if (reader == null) { + throw new NullPointerException("reader is null?"); + } + if (callback == null) { + throw new NullPointerException("callback is null?"); + } - CsvUtilReader utilReader = new CsvUtilReader(reader); + CsvUtilReader utilReader = new CsvUtilReader(reader); - callback.begin(server); + callback.begin(server); - int row = 0; + int row = 0; - if (hasHeader) { - String[] line = utilReader.readNext(); - if (addPropertiesFromHeader) { - addPropertiesFromHeader(line); - } - callback.readHeader(line); - } + if (hasHeader) { + String[] line = utilReader.readNext(); + if (addPropertiesFromHeader) { + addPropertiesFromHeader(line); + } + callback.readHeader(line); + } - try { - do { - ++row; - String[] line = utilReader.readNext(); - if (line == null) { - --row; - break; - } + try { + do { + ++row; + String[] line = utilReader.readNext(); + if (line == null) { + --row; + break; + } - if (callback.processLine(row, line)) { - // the line content is expected to be ok for processing - if (line.length != columnList.size()) { - // we have not got the expected number of columns - String msg = "Error at line " + row + ". Expected [" + columnList.size() + "] columns " - + "but instead we have [" + line.length + "]. Line[" + Arrays.toString(line) + "]"; - throw new TextException(msg); - } + if (callback.processLine(row, line)) { + // the line content is expected to be ok for processing + if (line.length != columnList.size()) { + // we have not got the expected number of columns + String msg = "Error at line " + row + ". Expected [" + columnList.size() + "] columns " + + "but instead we have [" + line.length + "]. Line[" + Arrays.toString(line) + "]"; + throw new TextException(msg); + } - T bean = buildBeanFromLineContent(row, line); + T bean = buildBeanFromLineContent(row, line); - callback.processBean(row, line, bean); + callback.processBean(row, line, bean); - } - } while (true); + } + } while (true); - callback.end(row); + callback.end(row); - } catch (Exception e) { - // notify that an error occurred so that any - // transaction can be rolled back if required - callback.endWithError(row, e); - throw e; - } - } + } catch (Exception e) { + // notify that an error occurred so that any + // transaction can be rolled back if required + callback.endWithError(row, e); + throw e; + } + } - private void addPropertiesFromHeader(String[] line) { - for (int i = 0; i < line.length; i++) { - ElPropertyValue elProp = descriptor.getElGetValue(line[i]); - if (elProp == null) { - throw new TextException("Property [" + line[i] + "] not found"); - } + private void addPropertiesFromHeader(String[] line) { + for (String aLine : line) { + ElPropertyValue elProp = descriptor.getElGetValue(aLine); + if (elProp == null) { + throw new TextException("Property [" + aLine + "] not found"); + } - if (Types.TIME == elProp.getJdbcType()) { - addProperty(line[i], TIME_PARSER); + if (Types.TIME == elProp.getJdbcType()) { + addProperty(aLine, TIME_PARSER); - } else if (isDateTimeType(elProp.getJdbcType())) { - addDateTime(line[i], null, null); + } else if (isDateTimeType(elProp.getJdbcType())) { + addDateTime(aLine, null, null); - } else if (elProp.isAssocProperty()) { - BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) elProp.getBeanProperty(); - String idProp = assocOne.getBeanDescriptor().getIdBinder().getIdProperty(); - addProperty(line[i] + "." + idProp); - } else { - addProperty(line[i]); - } - } - } + } else if (elProp.isAssocProperty()) { + BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) elProp.getBeanProperty(); + String idProp = assocOne.getBeanDescriptor().getIdBinder().getIdProperty(); + addProperty(aLine + "." + idProp); + } else { + addProperty(aLine); + } + } + } - private boolean isDateTimeType(int t) { + private boolean isDateTimeType(int t) { return t == Types.TIMESTAMP || t == Types.DATE || t == Types.TIME; } - @SuppressWarnings("unchecked") - protected T buildBeanFromLineContent(int row, String[] line) { + @SuppressWarnings("unchecked") + protected T buildBeanFromLineContent(int row, String[] line) { - try { - EntityBean entityBean = descriptor.createEntityBean(); - T bean = (T) entityBean; + try { + EntityBean entityBean = descriptor.createEntityBean(); + T bean = (T) entityBean; - int columnPos = 0; - for (; columnPos < line.length; columnPos++) { - convertAndSetColumn(columnPos, line[columnPos], entityBean); - } + int columnPos = 0; + for (; columnPos < line.length; columnPos++) { + convertAndSetColumn(columnPos, line[columnPos], entityBean); + } - return bean; - - } catch (RuntimeException e) { - String msg = "Error at line: " + row + " line[" + Arrays.toString(line) + "]"; - throw new RuntimeException(msg, e); - } - } + return bean; - protected void convertAndSetColumn(int columnPos, String strValue, EntityBean bean) { + } catch (RuntimeException e) { + String msg = "Error at line: " + row + " line[" + Arrays.toString(line) + "]"; + throw new RuntimeException(msg, e); + } + } - strValue = strValue.trim(); + protected void convertAndSetColumn(int columnPos, String strValue, EntityBean bean) { - if (strValue.isEmpty()) { - return; - } + strValue = strValue.trim(); - CsvColumn c = columnList.get(columnPos); - c.convertAndSet(strValue, bean); - } + if (strValue.isEmpty()) { + return; + } - /** - * Processes a column in the csv content. - */ - public static class CsvColumn { + CsvColumn c = columnList.get(columnPos); + c.convertAndSet(strValue, bean); + } - private final ExpressionPath path; - private final StringParser parser; + /** + * Processes a column in the csv content. + */ + public static class CsvColumn { - /** - * Constructor for the IGNORE column. - */ - private CsvColumn() { - this.path = null; - this.parser = null; - } + private final ExpressionPath path; + private final StringParser parser; - /** - * Construct with a property and parser. - */ - public CsvColumn(ExpressionPath path, StringParser parser) { - this.path = path; - this.parser = parser; - } + /** + * Constructor for the IGNORE column. + */ + private CsvColumn() { + this.path = null; + this.parser = null; + } - /** - * Convert the string to the appropriate value and set it to the bean. - */ - public void convertAndSet(String strValue, EntityBean bean) { + /** + * Construct with a property and parser. + */ + public CsvColumn(ExpressionPath path, StringParser parser) { + this.path = path; + this.parser = parser; + } - if (parser != null && path != null) { - Object value = parser.parse(strValue); - path.pathSet(bean, value); - } - } - } + /** + * Convert the string to the appropriate value and set it to the bean. + */ + public void convertAndSet(String strValue, EntityBean bean) { - /** - * A StringParser for converting custom date/time/datetime strings into - * appropriate java types (Date, Calendar, SQL Date, Time, Timestamp, JODA - * etc). - */ - private static class DateTimeParser implements StringParser { + if (parser != null && path != null) { + Object value = parser.parse(strValue); + path.pathSet(bean, value); + } + } + } - private final DateFormat dateFormat; - private final ExpressionPath path; - private final String format; + /** + * A StringParser for converting custom date/time/datetime strings into + * appropriate java types (Date, Calendar, SQL Date, Time, Timestamp, JODA + * etc). + */ + private static class DateTimeParser implements StringParser { - DateTimeParser(DateFormat dateFormat, String format, ExpressionPath path) { - this.dateFormat = dateFormat; - this.path = path; - this.format = format; - } + private final DateFormat dateFormat; + private final ExpressionPath path; + private final String format; - public Object parse(String value) { - try { - Date dt = dateFormat.parse(value); - return path.parseDateTime(dt.getTime()); + DateTimeParser(DateFormat dateFormat, String format, ExpressionPath path) { + this.dateFormat = dateFormat; + this.path = path; + this.format = format; + } - } catch (ParseException e) { - throw new TextException("Error parsing [" + value + "] using format[" + format + "]", e); - } - } + public Object parse(String value) { + try { + Date dt = dateFormat.parse(value); + return path.parseDateTime(dt.getTime()); - } + } catch (ParseException e) { + throw new TextException("Error parsing [" + value + "] using format[" + format + "]", e); + } + } + + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonBeanReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonBeanReader.java index 0497146e9..e6e2e720a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonBeanReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonBeanReader.java @@ -11,7 +11,7 @@ import java.io.IOException; /** * A 'context' for reading entity beans from JSON. *

- * This is used such that a load context and persistence context can be used to span multiple marshalling requests. + * This is used such that a load context and persistence context can be used to span multiple marshalling requests. *

*/ public class DJsonBeanReader implements JsonBeanReader { diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java index 21d6ffd6f..eef1f1d8f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java @@ -123,15 +123,15 @@ public class DJsonContext implements JsonContext { BeanDescriptor desc = getDescriptor(cls); ReadJson readJson = new ReadJson(desc, parser, options, determineObjectMapper(options)); - return new DJsonBeanReader(desc, readJson); + return new DJsonBeanReader<>(desc, readJson); } @Override public DJsonBeanReader createBeanReader(BeanType beanType, JsonParser parser, JsonReadOptions options) throws JsonIOException { - BeanDescriptor desc = (BeanDescriptor)beanType; + BeanDescriptor desc = (BeanDescriptor) beanType; ReadJson readJson = new ReadJson(desc, parser, options, determineObjectMapper(options)); - return new DJsonBeanReader(desc, readJson); + return new DJsonBeanReader<>(desc, readJson); } public List toList(Class cls, String json) throws JsonIOException { @@ -161,7 +161,7 @@ public class DJsonContext implements JsonContext { ReadJson readJson = new ReadJson(desc, src, options, determineObjectMapper(options)); try { - List list = new ArrayList(); + List list = new ArrayList<>(); JsonToken currentToken = src.getCurrentToken(); if (currentToken != JsonToken.START_ARRAY) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonScalar.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonScalar.java index c55c9be34..ed63ca3aa 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonScalar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonScalar.java @@ -21,7 +21,7 @@ public class DJsonScalar { public void write(JsonGenerator gen, Object value) throws IOException { if (value instanceof String) { - gen.writeString((String)value); + gen.writeString((String) value); } else { ScalarType scalarType = typeManager.getScalarType(value.getClass()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/ReadJson.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/ReadJson.java index e815de642..782ddd7e5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/ReadJson.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/ReadJson.java @@ -116,7 +116,7 @@ public class ReadJson { */ public void persistenceContextPut(Object beanId, T currentBean) { - persistenceContextPutIfAbsent(beanId, (EntityBean)currentBean, rootDesc); + persistenceContextPutIfAbsent(beanId, (EntityBean) currentBean, rootDesc); } /** @@ -132,7 +132,7 @@ public class ReadJson { Object existing = beanDesc.contextPutIfAbsent(persistenceContext, id, bean); if (existing != null) { - beanDesc.merge(bean, (EntityBean)existing); + beanDesc.merge(bean, (EntityBean) existing); } else { if (loadContext != null) { @@ -156,10 +156,10 @@ public class ReadJson { public ObjectMapper getObjectMapper() { if (objectMapper == null) { throw new IllegalStateException( - "Jackson ObjectMapper required but has not set. The ObjectMapper can be set on" - +" either the ServerConfig or on JsonReadOptions."); + "Jackson ObjectMapper required but has not set. The ObjectMapper can be set on" + + " either the ServerConfig or on JsonReadOptions."); } - return (ObjectMapper)objectMapper; + return (ObjectMapper) objectMapper; } /** @@ -214,7 +214,7 @@ public class ReadJson { * Typically this is used to read Transient properties where the type is unknown to Ebean. */ public Object readValueUsingObjectMapper(Class propertyType) throws IOException { - return getObjectMapper().readValue(parser, propertyType); + return getObjectMapper().readValue(parser, propertyType); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java index 11af1a92f..f7713cd4c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java @@ -50,7 +50,7 @@ public class WriteJson implements JsonWriter { this.visitors = visitors; this.objectMapper = objectMapper; this.include = include; - this.parentBeans = new ArrayStack(); + this.parentBeans = new ArrayStack<>(); this.pathStack = new PathStack(); } @@ -488,15 +488,15 @@ public class WriteJson implements JsonWriter { if (!isReferenceOnly()) { // render all the properties and invoke lazy loading if required BeanProperty[] props = desc.propertiesNonTransient(); - for (int j = 0; j < props.length; j++) { - if (isIncludeProperty(props[j])) { - props[j].jsonWrite(writeJson, currentBean); + for (BeanProperty prop1 : props) { + if (isIncludeProperty(prop1)) { + prop1.jsonWrite(writeJson, currentBean); } } props = desc.propertiesTransient(); - for (int j = 0; j < props.length; j++) { - if (isIncludeTransientProperty(props[j])) { - props[j].jsonWrite(writeJson, currentBean); + for (BeanProperty prop : props) { + if (isIncludeTransientProperty(prop)) { + prop.jsonWrite(writeJson, currentBean); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/AutoCommitTransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/AutoCommitTransactionManager.java index c2c40ebe4..934d5fabc 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/AutoCommitTransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/AutoCommitTransactionManager.java @@ -17,8 +17,8 @@ import java.sql.Connection; public class AutoCommitTransactionManager extends TransactionManager { public AutoCommitTransactionManager(boolean localL2Caching, ServerConfig serverConfig, ClusterManager clusterManager, BackgroundExecutor backgroundExecutor, - DocStoreUpdateProcessor indexUpdateProcessor, BeanDescriptorManager descMgr) { - + DocStoreUpdateProcessor indexUpdateProcessor, BeanDescriptorManager descMgr) { + super(localL2Caching, serverConfig, clusterManager, backgroundExecutor, indexUpdateProcessor, descMgr); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIdMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIdMap.java index adc4180d2..dbe4c0f68 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIdMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIdMap.java @@ -13,7 +13,7 @@ import java.util.Map; */ public final class BeanPersistIdMap { - private final Map beanMap = new LinkedHashMap(); + private final Map beanMap = new LinkedHashMap<>(); public String toString() { return beanMap.toString(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java index 9c888394b..4bc583d9b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java @@ -98,7 +98,7 @@ public class BeanPersistIds { if (count < 1) { return null; } - List idList = new ArrayList(count); + List idList = new ArrayList<>(count); for (int i = 0; i < count; i++) { idList.add(idBinder.readData(dataInput)); } @@ -186,21 +186,21 @@ public class BeanPersistIds { private void addInsertId(Serializable id) { if (insertIds == null) { - insertIds = new ArrayList(); + insertIds = new ArrayList<>(); } insertIds.add(id); } private void addUpdateId(Serializable id) { if (updateIds == null) { - updateIds = new ArrayList(); + updateIds = new ArrayList<>(); } updateIds.add(id); } private void addDeleteId(Serializable id) { if (deleteIds == null) { - deleteIds = new ArrayList(); + deleteIds = new ArrayList<>(); } deleteIds.add(id); } @@ -222,14 +222,12 @@ public class BeanPersistIds { beanDescriptor.queryCacheClear(); if (updateIds != null) { - for (int i = 0; i < updateIds.size(); i++) { - Object id = updateIds.get(i); + for (Object id : updateIds) { beanDescriptor.cacheHandleDeleteById(id); } } if (deleteIds != null) { - for (int i = 0; i < deleteIds.size(); i++) { - Object id = deleteIds.get(i); + for (Object id : deleteIds) { beanDescriptor.cacheHandleDeleteById(id); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java index c82d8aac6..ca634cf73 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java @@ -10,7 +10,7 @@ import java.util.Set; public class BulkEventListenerMap { - private final HashMap map = new HashMap(); + private final HashMap map = new HashMap<>(); public BulkEventListenerMap(List listeners) { @@ -48,15 +48,15 @@ public class BulkEventListenerMap { private static class Entry { - final List listeners = new ArrayList(); + final List listeners = new ArrayList<>(); private void add(BulkTableEventListener l) { listeners.add(l); } private void process(BulkTableEvent event) { - for (int i = 0; i < listeners.size(); i++) { - listeners.get(i).process(event); + for (BulkTableEventListener listener : listeners) { + listener.process(event); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/DefaultPersistenceContext.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/DefaultPersistenceContext.java index fa7970edf..41a4dc6ad 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/DefaultPersistenceContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/DefaultPersistenceContext.java @@ -30,7 +30,7 @@ public final class DefaultPersistenceContext implements PersistenceContext { /** * Map used hold caches. One cache per bean type. */ - private final HashMap, ClassContext> typeCache = new HashMap, ClassContext>(); + private final HashMap, ClassContext> typeCache = new HashMap<>(); private final Monitor monitor = new Monitor(); @@ -134,7 +134,7 @@ public final class DefaultPersistenceContext implements PersistenceContext { private static class ClassContext { - private final Map map = new HashMap(); + private final Map map = new HashMap<>(); private Set deleteSet; @@ -187,7 +187,7 @@ public final class DefaultPersistenceContext implements PersistenceContext { private void deleted(Object id) { if (deleteSet == null) { - deleteSet = new HashSet(); + deleteSet = new HashSet<>(); } deleteSet.add(id); map.remove(id); diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java index 55b47ff76..72ce09be7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java @@ -1,8 +1,11 @@ package com.avaje.ebeaninternal.server.transaction; +import com.avaje.ebean.annotation.DocStoreMode; import com.avaje.ebeaninternal.server.cache.CacheChangeSet; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; +import com.avaje.ebeanservice.docstore.api.support.DocStoreDeleteEvent; import java.io.Serializable; import java.util.Collection; @@ -10,16 +13,12 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import com.avaje.ebean.annotation.DocStoreMode; -import com.avaje.ebeanservice.docstore.api.support.DocStoreDeleteEvent; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; - /** * Beans deleted by Id used for updating L2 Cache. */ public final class DeleteByIdMap { - private final Map beanMap = new LinkedHashMap(); + private final Map beanMap = new LinkedHashMap<>(); public String toString() { return beanMap.toString(); @@ -31,8 +30,8 @@ public final class DeleteByIdMap { List idValues = deleteIds.getDeleteIds(); if (idValues != null) { d.queryCacheClear(changeSet); - for (int i = 0; i < idValues.size(); i++) { - d.cacheHandleDeleteById(idValues.get(i), changeSet); + for (Object idValue : idValues) { + d.cacheHandleDeleteById(idValue, changeSet); } } } @@ -61,8 +60,8 @@ public final class DeleteByIdMap { public void addList(BeanDescriptor desc, List idList) { BeanPersistIds r = getPersistIds(desc); - for (int i = 0; i < idList.size(); i++) { - r.addId(PersistRequest.Type.DELETE, (Serializable) idList.get(i)); + for (Object anIdList : idList) { + r.addId(PersistRequest.Type.DELETE, (Serializable) anIdList); } } @@ -89,11 +88,11 @@ public final class DeleteByIdMap { String queueId = desc.getDocStoreQueueId(); List idValues = deleteIds.getDeleteIds(); if (idValues != null) { - for (int i = 0; i < idValues.size(); i++) { + for (Object idValue : idValues) { if (queue) { - docStoreUpdates.queueDelete(queueId, idValues.get(i)); + docStoreUpdates.queueDelete(queueId, idValue); } else { - docStoreUpdates.addDelete(new DocStoreDeleteEvent(desc, idValues.get(i))); + docStoreUpdates.addDelete(new DocStoreDeleteEvent(desc, idValue)); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitJdbcTransaction.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitJdbcTransaction.java index b8fc830da..fd33ea3ee 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitJdbcTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitJdbcTransaction.java @@ -6,7 +6,7 @@ import java.sql.SQLException; /** * This only works for Postgres and H2 (and doesn't work for Oracle). - * + *

* Uses explicit begin statement to start the transactions. */ public class ExplicitJdbcTransaction extends JdbcTransaction { diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitTransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitTransactionManager.java index 70b4ee7b1..3875f5a8c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitTransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitTransactionManager.java @@ -17,7 +17,7 @@ import java.sql.Connection; public class ExplicitTransactionManager extends TransactionManager { public ExplicitTransactionManager(boolean localL2Caching, ServerConfig serverConfig, ClusterManager clusterManager, BackgroundExecutor backgroundExecutor, - DocStoreUpdateProcessor indexUpdateProcessor, BeanDescriptorManager descMgr) { + DocStoreUpdateProcessor indexUpdateProcessor, BeanDescriptorManager descMgr) { super(localL2Caching, serverConfig, clusterManager, backgroundExecutor, indexUpdateProcessor, descMgr); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java index 4478d10a2..9a13bbe8e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java @@ -10,9 +10,9 @@ import com.avaje.ebean.event.changelog.BeanChange; import com.avaje.ebean.event.changelog.ChangeSet; import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.api.TransactionEvent; +import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.lib.util.Str; import com.avaje.ebeaninternal.server.persist.BatchControl; import org.slf4j.Logger; @@ -235,6 +235,7 @@ public class JdbcTransaction implements SpiTransaction { return logPrefix; } + @Override public String toString() { return logPrefix; } @@ -255,7 +256,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public void register(TransactionCallback callback) { if (callbackList == null) { - callbackList = new ArrayList(4); + callbackList = new ArrayList<>(4); } callbackList.add(callback); } @@ -324,6 +325,7 @@ public class JdbcTransaction implements SpiTransaction { this.docStoreBatchSize = docStoreBatchSize; } + @Override public DocStoreMode getDocStoreMode() { return docStoreMode; } @@ -336,7 +338,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public void registerDeferred(PersistDeferredRelationship derived) { if (deferredList == null) { - deferredList = new ArrayList(); + deferredList = new ArrayList<>(); } deferredList.add(derived); } @@ -350,7 +352,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public void registerDeleteBean(Integer persistingBean) { if (deletingBeansHash == null) { - deletingBeansHash = new HashSet(); + deletingBeansHash = new HashSet<>(); } deletingBeansHash.add(persistingBean); } @@ -388,7 +390,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public boolean isRegisteredBean(Object bean) { if (persistingBeans == null) { - persistingBeans = new IdentityHashMap(); + persistingBeans = new IdentityHashMap<>(); } return (persistingBeans.put(bean, PLACEHOLDER) != null); } @@ -400,8 +402,8 @@ public class JdbcTransaction implements SpiTransaction { @Override public boolean isSaveAssocManyIntersection(String intersectionTable, String beanName) { if (m2mIntersectionSave == null) { - // first attempt so yes allow this m2m intersection direction - m2mIntersectionSave = new HashMap(); + // first attempt so yes allow this m2m intersection direction + m2mIntersectionSave = new HashMap<>(); m2mIntersectionSave.put(intersectionTable, beanName); return true; } @@ -412,8 +414,8 @@ public class JdbcTransaction implements SpiTransaction { return true; } - // only allow if save coming from the same bean type - // to stop saves coming from both directions of m2m + // only allow if save coming from the same bean type + // to stop saves coming from both directions of m2m return existingBean.equals(beanName); } @@ -480,6 +482,7 @@ public class JdbcTransaction implements SpiTransaction { this.updateAllLoadedProperties = updateAllLoadedProperties; } + @Override public Boolean isUpdateAllLoadedProperties() { return updateAllLoadedProperties; } @@ -599,6 +602,7 @@ public class JdbcTransaction implements SpiTransaction { } } + @Override public void checkBatchEscalationOnCollection() { if (batchMode == PersistBatch.NONE && batchOnCascadeMode != PersistBatch.NONE) { batchMode = batchOnCascadeMode; @@ -606,6 +610,7 @@ public class JdbcTransaction implements SpiTransaction { } } + @Override public void flushBatchOnCollection() { if (batchOnCascadeSet) { if (batchControl != null) { @@ -634,6 +639,19 @@ public class JdbcTransaction implements SpiTransaction { batchMode = oldBatchMode; } + @Override + public void flushBatchOnRollback() { + if (batchControl != null) { + if (logger.isTraceEnabled()) { + logger.trace("... flushBatchOnRollback"); + } + batchControl.clear(); + } + // restore the previous batch mode + batchMode = oldBatchMode; + } + + @Override public boolean checkBatchEscalationOnCascade(PersistRequestBean request) { if (isBatch(batchMode, request.getType())) { @@ -1064,7 +1082,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public void putUserObject(String name, Object value) { if (userObjects == null) { - userObjects = new HashMap(); + userObjects = new HashMap<>(); } userObjects.put(name, value); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/JtaTransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/JtaTransactionManager.java index 8162164fa..0917a56d3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/JtaTransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/JtaTransactionManager.java @@ -151,7 +151,7 @@ public class JtaTransactionManager implements ExternalTransactionManager { } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, - SecurityException, IllegalStateException, SystemException { + SecurityException, IllegalStateException, SystemException { } public int getStatus() throws SystemException { diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java index f47dcb04e..2ecb1a2bf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java @@ -6,10 +6,10 @@ import com.avaje.ebeaninternal.api.TransactionEvent; import com.avaje.ebeaninternal.api.TransactionEventTable; import com.avaje.ebeaninternal.api.TransactionEventTable.TableIUD; import com.avaje.ebeaninternal.server.cache.CacheChangeSet; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import com.avaje.ebeaninternal.server.cluster.ClusterManager; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -152,13 +152,11 @@ public final class PostCommitProcessing { * In background notify persist listeners, cluster and document store. */ Runnable backgroundNotify() { - return new Runnable() { - public void run() { - processCacheChanges(cacheChanges); - localPersistListenersNotify(); - notifyCluster(); - processDocStoreUpdates(); - } + return () -> { + processCacheChanges(cacheChanges); + localPersistListenersNotify(); + notifyCluster(); + processDocStoreUpdates(); }; } @@ -173,8 +171,8 @@ public final class PostCommitProcessing { private void localPersistListenersNotify() { if (persistBeanRequests != null) { - for (int i = 0; i < persistBeanRequests.size(); i++) { - persistBeanRequests.get(i).notifyLocalPersistListener(); + for (PersistRequestBean persistBeanRequest : persistBeanRequests) { + persistBeanRequest.notifyLocalPersistListener(); } } TransactionEventTable eventTables = event.getEventTables(); @@ -193,8 +191,8 @@ public final class PostCommitProcessing { } BeanPersistIdMap m = new BeanPersistIdMap(); - for (int i = 0; i < persistBeanRequests.size(); i++) { - persistBeanRequests.get(i).addToPersistMap(m); + for (PersistRequestBean persistBeanRequest : persistBeanRequests) { + persistBeanRequest.addToPersistMap(m); } return m; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java index 42b79bd3f..3d2735bce 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java @@ -10,7 +10,7 @@ import java.util.List; public class RemoteTransactionEvent implements Runnable { - private final List beanPersistList = new ArrayList(); + private final List beanPersistList = new ArrayList<>(); private List tableList; @@ -49,8 +49,8 @@ public class RemoteTransactionEvent implements Runnable { public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { if (tableList != null) { - for (int i = 0; i < tableList.size(); i++) { - tableList.get(i).writeBinaryMessage(msgList); + for (TableIUD aTableList : tableList) { + aTableList.writeBinaryMessage(msgList); } } @@ -60,15 +60,15 @@ public class RemoteTransactionEvent implements Runnable { } } - for (int i = 0; i < beanPersistList.size(); i++) { - beanPersistList.get(i).writeBinaryMessage(msgList); + for (BeanPersistIds aBeanPersistList : beanPersistList) { + aBeanPersistList.writeBinaryMessage(msgList); } } public boolean isEmpty() { return beanPersistList.isEmpty() - && (tableList == null || tableList.isEmpty()) - && (deleteByIdMap == null || deleteByIdMap.isEmpty()); + && (tableList == null || tableList.isEmpty()) + && (deleteByIdMap == null || deleteByIdMap.isEmpty()); } public void addBeanPersistIds(BeanPersistIds beanPersist) { @@ -77,7 +77,7 @@ public class RemoteTransactionEvent implements Runnable { public void addTableIUD(TableIUD tableIud) { if (tableList == null) { - tableList = new ArrayList(4); + tableList = new ArrayList<>(4); } tableList.add(tableIud); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java index 4d42916e4..9afe59a23 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java @@ -390,8 +390,7 @@ public class TransactionManager { List tableIUDList = remoteEvent.getTableIUDList(); if (tableIUDList != null) { - for (int i = 0; i < tableIUDList.size(); i++) { - TableIUD tableIUD = tableIUDList.get(i); + for (TableIUD tableIUD : tableIUDList) { beanDescriptorManager.cacheNotify(tableIUD); } } @@ -400,8 +399,8 @@ public class TransactionManager { // processes both Bean IUD and DeleteById List beanPersistList = remoteEvent.getBeanPersistList(); if (beanPersistList != null) { - for (int i = 0; i < beanPersistList.size(); i++) { - beanPersistList.get(i).notifyCacheAndListener(); + for (BeanPersistIds aBeanPersistList : beanPersistList) { + aBeanPersistList.notifyCacheAndListener(); } } } @@ -422,12 +421,7 @@ public class TransactionManager { if (changeLogPrepare.prepare(changeSet)) { // call the log method in background - backgroundExecutor.execute(new Runnable() { - @Override - public void run() { - changeLogListener.log(changeSet); - } - }); + backgroundExecutor.execute(() -> changeLogListener.log(changeSet)); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionMap.java index d02a84915..e4f43fcde 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionMap.java @@ -14,7 +14,7 @@ public class TransactionMap { /** * Map of State by serverName. */ - private final HashMap map = new HashMap(); + private final HashMap map = new HashMap<>(); public String toString() { return map.toString(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java b/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java index 9bd2d23b7..349c3757b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java @@ -15,27 +15,27 @@ interface ArrayElementConverter { /** * The UUID converter implementation. */ - ArrayElementConverter UUID = new UuidConverter(); + ArrayElementConverter UUID = new UuidConverter(); /** * The String converter implementation. */ - ArrayElementConverter STRING = new StringConverter(); + ArrayElementConverter STRING = new StringConverter(); /** * The Long converter implementation. */ - ArrayElementConverter LONG = new LongConverter(); + ArrayElementConverter LONG = new LongConverter(); /** * The Integer converter implementation. */ - ArrayElementConverter INTEGER = new IntegerConverter(); + ArrayElementConverter INTEGER = new IntegerConverter(); /** * The Double converter implementation. */ - ArrayElementConverter DOUBLE = new DoubleConverter(); + ArrayElementConverter DOUBLE = new DoubleConverter(); class LongConverter implements ArrayElementConverter { @@ -87,6 +87,7 @@ interface ArrayElementConverter { class NoopConverter implements ArrayElementConverter { + @SuppressWarnings("unchecked") @Override public T toElement(Object rawValue) { return (T) rawValue; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java b/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java index 2473e140a..b576e7ebb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java @@ -140,7 +140,7 @@ public final class ConvertInetAddresses { // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw new IllegalArgumentException( - String.format("'%s' is not an IP string literal.", ipString)); + String.format("'%s' is not an IP string literal.", ipString)); } try { @@ -159,8 +159,7 @@ public final class ConvertInetAddresses { * {@link IPAddressUtil#textToNumericFormatV4} or * {@link IPAddressUtil#textToNumericFormatV6}. */ - throw new IllegalArgumentException( - String.format("'%s' is extremely broken.", ipString), e); + throw new IllegalArgumentException(String.format("'%s' is extremely broken.", ipString), e); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java index 7def927ec..24d23a5fa 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java @@ -87,8 +87,8 @@ public final class CtCompoundType implements ScalarDataReader { } public void loadIgnore(DataReader dataReader) { - for (int i = 0; i < propReaders.length; i++) { - propReaders[i].loadIgnore(dataReader); + for (ScalarDataReader propReader : propReaders) { + propReader.loadIgnore(dataReader); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java index 79fe9f2e4..fdfea3f00 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java @@ -14,16 +14,16 @@ import java.util.Set; */ public final class CtCompoundTypeScalarList { - private final LinkedHashMap> scalarProps = new LinkedHashMap>(); + private final LinkedHashMap> scalarProps = new LinkedHashMap<>(); - private final LinkedHashMap compoundProperties = new LinkedHashMap(); + private final LinkedHashMap compoundProperties = new LinkedHashMap<>(); /** * Return the list of non-scalar properties. These occur when compound types are nested. */ public List getNonScalarProperties() { - List nonScalarProps = new ArrayList(); + List nonScalarProps = new ArrayList<>(); for (String propKey : compoundProperties.keySet()) { if (!scalarProps.containsKey(propKey)) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java index 6ef22fba2..867a6c0c9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java @@ -66,7 +66,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Currency; +import java.util.EnumSet; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -145,7 +147,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { private final ScalarType classType = new ScalarTypeClass(); - private final List> customScalarTypes = new ArrayList>(); + private final List> customScalarTypes = new ArrayList<>(); private final CheckImmutable checkImmutable; @@ -198,9 +200,9 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { this.checkImmutable = new CheckImmutable(this); this.reflectScalarBuilder = new ReflectionBasedTypeBuilder(this); - this.compoundTypeMap = new ConcurrentHashMap, CtCompoundType>(); - this.typeMap = new ConcurrentHashMap, ScalarType>(); - this.nativeMap = new ConcurrentHashMap>(); + this.compoundTypeMap = new ConcurrentHashMap<>(); + this.typeMap = new ConcurrentHashMap<>(); + this.nativeMap = new ConcurrentHashMap<>(); boolean objectMapperPresent = config.getClassLoadConfig().isJacksonObjectMapperPresent(); this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : null; @@ -330,7 +332,25 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { logAdd(scalarType); } - protected void logAdd(ScalarType scalarType) { + /** + * Register the ScalarType for an enum. This is special in the sense that an Enum + * can have many classes if it uses method overrides and we need to register all + * the variations/classes for the enum. + */ + @Override + public void addEnumType(ScalarType scalarType, Class enumClass) { + + Set> mappedClasses = new HashSet<>(); + for (Object value : EnumSet.allOf(enumClass).toArray()) { + mappedClasses.add(value.getClass()); + } + for (Class cls : mappedClasses) { + typeMap.put(cls, scalarType); + } + logAdd(scalarType); + } + + private void logAdd(ScalarType scalarType) { if (logger.isDebugEnabled()) { String msg = "ScalarType register [" + scalarType.getClass().getName() + "]"; msg += " for [" + scalarType.getType().getName() + "]"; @@ -357,8 +377,8 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { if (found == null) { if (type.getName().equals("org.joda.time.LocalTime")) { throw new IllegalStateException( - "ScalarType of Joda LocalTime not defined. You need to set ServerConfig.jodaLocalTimeMode to" - + " either 'normal' or 'utc'. UTC is the old mode using UTC timezone but local time zone is now preferred as 'normal' mode."); + "ScalarType of Joda LocalTime not defined. You need to set ServerConfig.jodaLocalTimeMode to" + + " either 'normal' or 'utc'. UTC is the old mode using UTC timezone but local time zone is now preferred as 'normal' mode."); } found = checkInterfaceTypes(type); } @@ -379,15 +399,13 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { return null; } - public ScalarDataReader getScalarDataReader(Class propertyType, int sqlType) { + private ScalarDataReader getScalarDataReader(Class propertyType, int sqlType) { if (sqlType == 0) { return recursiveCreateScalarDataReader(propertyType); } - for (int i = 0; i < customScalarTypes.size(); i++) { - ScalarType customScalarType = customScalarTypes.get(i); - + for (ScalarType customScalarType : customScalarTypes) { if (sqlType == customScalarType.getJdbcType() && (propertyType.equals(customScalarType.getType()))) { return customScalarType; @@ -398,7 +416,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { throw new RuntimeException(msg); } - public ScalarDataReader getScalarDataReader(Class type) { + private ScalarDataReader getScalarDataReader(Class type) { ScalarDataReader reader = typeMap.get(type); if (reader == null) { reader = compoundTypeMap.get(type); @@ -585,7 +603,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { return value; } - protected boolean isIntegerType(String s) { + boolean isIntegerType(String s) { if (isLeadingZeros(s)) { return false; } @@ -614,13 +632,13 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { boolean integerType = true; - Map nameValueMap = new HashMap(); + Map nameValueMap = new HashMap<>(); Field[] fields = enumType.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - EnumValue enumValue = fields[i].getAnnotation(EnumValue.class); + for (Field field : fields) { + EnumValue enumValue = field.getAnnotation(EnumValue.class); if (enumValue != null) { - nameValueMap.put(fields[i].getName(), enumValue.value()); + nameValueMap.put(field.getName(), enumValue.value()); if (integerType && !isIntegerType(enumValue.value())) { // will treat the values as strings integerType = false; @@ -647,11 +665,11 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { public ScalarType createEnumScalarType(Class> enumType) { Method[] methods = enumType.getMethods(); - for (int i = 0; i < methods.length; i++) { - DbEnumValue dbValue = methods[i].getAnnotation(DbEnumValue.class); + for (Method method : methods) { + DbEnumValue dbValue = method.getAnnotation(DbEnumValue.class); if (dbValue != null) { boolean integerValues = DbEnumType.INTEGER == dbValue.storage(); - return createEnumScalarTypeDbValue(enumType, methods[i], integerValues); + return createEnumScalarTypeDbValue(enumType, method, integerValues); } } @@ -668,15 +686,15 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { */ private ScalarType createEnumScalarTypeDbValue(Class> enumType, Method method, boolean integerType) { - Map nameValueMap = new HashMap(); + Map nameValueMap = new HashMap<>(); Enum[] enumConstants = enumType.getEnumConstants(); - for (int i = 0; i < enumConstants.length; i++) { + for (Enum enumConstant : enumConstants) { try { - Object value = method.invoke(enumConstants[i]); - nameValueMap.put(enumConstants[i].name(), value.toString()); + Object value = method.invoke(enumConstant); + nameValueMap.put(enumConstant.name(), value.toString()); } catch (Exception e) { - throw new IllegalArgumentException("Error trying to invoke DbEnumValue method on " + enumConstants[i], e); + throw new IllegalArgumentException("Error trying to invoke DbEnumValue method on " + enumConstant, e); } } if (nameValueMap.isEmpty()) { @@ -723,7 +741,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { * interface and register it with this TypeManager. *

*/ - protected void initialiseCustomScalarTypes(JsonConfig.DateTime mode, BootupClasses bootupClasses) { + private void initialiseCustomScalarTypes(JsonConfig.DateTime mode, BootupClasses bootupClasses) { ScalarTypeLongToTimestamp longToTimestamp = new ScalarTypeLongToTimestamp(mode); @@ -731,8 +749,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { List>> foundTypes = bootupClasses.getScalarTypes(); - for (int i = 0; i < foundTypes.size(); i++) { - Class> cls = foundTypes.get(i); + for (Class> cls : foundTypes) { try { ScalarType scalarType; @@ -773,12 +790,12 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } @SuppressWarnings({"unchecked", "rawtypes"}) - protected void initialiseScalarConverters(BootupClasses bootupClasses) { + private void initialiseScalarConverters(BootupClasses bootupClasses) { List>> foundTypes = bootupClasses.getScalarConverters(); - for (int i = 0; i < foundTypes.size(); i++) { - Class cls = foundTypes.get(i); + for (Class> foundType : foundTypes) { + Class cls = foundType; try { Class[] paramTypes = TypeReflectHelper.getParams(cls, ScalarTypeConverter.class); @@ -809,12 +826,12 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } - protected void initialiseCompoundTypes(BootupClasses bootupClasses) { + private void initialiseCompoundTypes(BootupClasses bootupClasses) { List>> compoundTypes = bootupClasses.getCompoundTypes(); - for (int j = 0; j < compoundTypes.size(); j++) { + for (Class> compoundType1 : compoundTypes) { - Class type = compoundTypes.get(j); + Class type = compoundType1; try { Class[] paramTypes = TypeReflectHelper.getParams(type, CompoundType.class); @@ -835,7 +852,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } @SuppressWarnings({"unchecked", "rawtypes"}) - protected CtCompoundType createCompoundScalarDataReader(Class compoundTypeClass, CompoundType compoundType, String info) { + private CtCompoundType createCompoundScalarDataReader(Class compoundTypeClass, CompoundType compoundType, String info) { CtCompoundType ctCompoundType = compoundTypeMap.get(compoundTypeClass); if (ctCompoundType != null) { @@ -879,8 +896,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { // determine the types from generic parameter types using reflection Class[] propParamTypes = TypeReflectHelper.getParams(prop.getClass(), CompoundTypeProperty.class); if (propParamTypes.length != 2) { - throw new RuntimeException("Expecting 2 generic paramter types but got " + Arrays.toString(propParamTypes) + " for " - + prop.getClass()); + throw new RuntimeException("Expecting 2 generic paramter types but got " + Arrays.toString(propParamTypes) + " for " + prop.getClass()); } return propParamTypes[1]; @@ -890,7 +906,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { /** * Add support for Jackson's JsonNode mapping to Clob, Blob, Varchar, JSON and JSONB. */ - protected void initialiseJacksonTypes(ServerConfig config) { + private void initialiseJacksonTypes(ServerConfig config) { if (objectMapper != null) { @@ -913,7 +929,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } } - protected void initialiseJavaTimeTypes(JsonConfig.DateTime mode, ServerConfig config) { + private void initialiseJavaTimeTypes(JsonConfig.DateTime mode, ServerConfig config) { if (java7Present) { typeMap.put(java.nio.file.Path.class, new ScalarTypePath()); @@ -950,7 +966,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { * Detect if Joda classes are in the classpath and if so register the Joda * data types. */ - protected void initialiseJodaTypes(JsonConfig.DateTime mode, ServerConfig config) { + private void initialiseJodaTypes(JsonConfig.DateTime mode, ServerConfig config) { // detect if Joda classes are in the classpath if (config.getClassLoadConfig().isJodaTimePresent()) { @@ -978,7 +994,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { * Register all the standard types supported. This is the standard JDBC types * plus some other common types such as java.util.Date and java.util.Calendar. */ - protected void initialiseStandard(JsonConfig.DateTime mode, ServerConfig config) { + private void initialiseStandard(JsonConfig.DateTime mode, ServerConfig config) { DatabasePlatform databasePlatform = config.getDatabasePlatform(); int platformClobType = databasePlatform.getClobDbType(); @@ -1010,7 +1026,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { nativeMap.put(Types.BIT, booleanType); } - ServerConfig.DbUuid dbUuid = config.getDbUuid(); + ServerConfig.DbUuid dbUuid = config.getDbTypeConfig().getDbUuid(); if (offlineMigrationGeneration || (databasePlatform.isNativeUuidType() && dbUuid.useNativeType())) { typeMap.put(UUID.class, new ScalarTypeUUIDNative()); @@ -1043,7 +1059,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { nativeMap.put(Types.CLOB, clobType); } else { // for Postgres Clobs handled by Varchar ScalarType... - ScalarType platClobScalarType = nativeMap.get(Integer.valueOf(platformClobType)); + ScalarType platClobScalarType = nativeMap.get(platformClobType); if (platClobScalarType == null) { throw new IllegalArgumentException("Type for dbPlatform clobType [" + clobType + "] not found."); } @@ -1060,7 +1076,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { nativeMap.put(Types.BLOB, blobType); } else { // for Postgres Blobs handled by LongVarbinary ScalarType... - ScalarType platBlobScalarType = nativeMap.get(Integer.valueOf(platformBlobType)); + ScalarType platBlobScalarType = nativeMap.get(platformBlobType); if (platBlobScalarType == null) { throw new IllegalArgumentException("Type for dbPlatform blobType [" + blobType + "] not found."); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbValueMap.java b/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbValueMap.java index 742aa864a..53c56172e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbValueMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbValueMap.java @@ -46,9 +46,9 @@ public abstract class EnumToDbValueMap { public EnumToDbValueMap(boolean allowNulls, boolean isIntegerType) { this.allowNulls = allowNulls; this.isIntegerType = isIntegerType; - this.keyMap = new LinkedHashMap(); - this.valueMap = new LinkedHashMap(); - this.nameMap = new HashMap(); + this.keyMap = new LinkedHashMap<>(); + this.valueMap = new LinkedHashMap<>(); + this.nameMap = new HashMap<>(); } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java index e00afac15..26b4e726a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java @@ -19,7 +19,7 @@ public final class ImmutableCompoundTypeBuilder { } }; - private final Map, Entry> entryMap = new HashMap, Entry>(); + private final Map, Entry> entryMap = new HashMap<>(); /** * Clear the cache of partial compound objects. @@ -80,7 +80,7 @@ public final class ImmutableCompoundTypeBuilder { private Entry(CtCompoundType ct) { this.ct = ct; - this.valueMap = new HashMap(); + this.valueMap = new HashMap<>(); } private Object set(String propName, Object value) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java b/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java index 6f308c516..b553d550c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java @@ -12,7 +12,7 @@ public class LongToTimestampConverter implements ScalarTypeConverter implements Collection { } public Iterator iterator() { - return new ModifyAwareIterator(owner, c.iterator()); + return new ModifyAwareIterator<>(owner, c.iterator()); } public boolean remove(Object o) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java index 2e17c0c66..7dd01366f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java @@ -61,7 +61,7 @@ public class ModifyAwareList implements List, ModifyAwareOwner { @Override public Iterator iterator() { - return new ModifyAwareIterator(owner, list.iterator()); + return new ModifyAwareIterator<>(owner, list.iterator()); } @Override @@ -157,17 +157,17 @@ public class ModifyAwareList implements List, ModifyAwareOwner { @Override public ListIterator listIterator() { - return new ModifyAwareListIterator(owner, list.listIterator()); + return new ModifyAwareListIterator<>(owner, list.listIterator()); } @Override public ListIterator listIterator(int index) { - return new ModifyAwareListIterator(owner, list.listIterator(index)); + return new ModifyAwareListIterator<>(owner, list.listIterator(index)); } @Override public List subList(int fromIndex, int toIndex) { - return new ModifyAwareList(owner, list.subList(fromIndex, toIndex)); + return new ModifyAwareList<>(owner, list.subList(fromIndex, toIndex)); } /** @@ -175,8 +175,8 @@ public class ModifyAwareList implements List, ModifyAwareOwner { */ public ModifyAwareSet asSet() { - LinkedHashSet set = new LinkedHashSet(); + LinkedHashSet set = new LinkedHashSet<>(); set.addAll(list); - return new ModifyAwareSet(owner, set); + return new ModifyAwareSet<>(owner, set); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareMap.java b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareMap.java index 724dde7e7..36693628a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareMap.java @@ -102,17 +102,17 @@ public class ModifyAwareMap implements Map, ModifyAwareOwner { @Override public Set keySet() { - return new ModifyAwareSet(this, map.keySet()); + return new ModifyAwareSet<>(this, map.keySet()); } @Override public Collection values() { - return new ModifyAwareCollection(this, map.values()); + return new ModifyAwareCollection<>(this, map.values()); } @Override public Set> entrySet() { - return new ModifyAwareSet>(this, map.entrySet()); + return new ModifyAwareSet<>(this, map.entrySet()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java index 4aa61b15a..ff6a51a53 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java @@ -25,7 +25,7 @@ public class ScalarTypeArrayList extends ScalarTypeJsonCollection { private static ScalarTypeArrayList LONG = new ScalarTypeArrayList("bigint", DocPropertyType.LONG, ArrayElementConverter.LONG); private static ScalarTypeArrayList INTEGER = new ScalarTypeArrayList("integer", DocPropertyType.INTEGER, ArrayElementConverter.INTEGER); private static ScalarTypeArrayList DOUBLE = new ScalarTypeArrayList("float", DocPropertyType.DOUBLE, ArrayElementConverter.DOUBLE); - private static ScalarTypeArrayList STRING = new ScalarTypeArrayList("varchar", DocPropertyType.STRING, ArrayElementConverter.STRING); + private static ScalarTypeArrayList STRING = new ScalarTypeArrayList("varchar", DocPropertyType.TEXT, ArrayElementConverter.STRING); static PlatformArrayTypeFactory factory() { return new Factory(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayListH2.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayListH2.java index b9b4175d8..3c620a369 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayListH2.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayListH2.java @@ -16,7 +16,7 @@ class ScalarTypeArrayListH2 extends ScalarTypeArrayList { private static ScalarTypeArrayListH2 LONG = new ScalarTypeArrayListH2("bigint", DocPropertyType.LONG, ArrayElementConverter.LONG); private static ScalarTypeArrayListH2 INTEGER = new ScalarTypeArrayListH2("integer", DocPropertyType.INTEGER, ArrayElementConverter.INTEGER); private static ScalarTypeArrayListH2 DOUBLE = new ScalarTypeArrayListH2("double", DocPropertyType.DOUBLE, ArrayElementConverter.DOUBLE); - private static ScalarTypeArrayListH2 STRING = new ScalarTypeArrayListH2("varchar", DocPropertyType.STRING, ArrayElementConverter.STRING); + private static ScalarTypeArrayListH2 STRING = new ScalarTypeArrayListH2("varchar", DocPropertyType.TEXT, ArrayElementConverter.STRING); static PlatformArrayTypeFactory factory() { return new ScalarTypeArrayListH2.Factory(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBaseVarchar.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBaseVarchar.java index bc6c6817a..fabc01fe2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBaseVarchar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBaseVarchar.java @@ -129,7 +129,7 @@ public abstract class ScalarTypeBaseVarchar extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.TEXT; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDuration.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDuration.java index 6f0dc11a4..478515765 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDuration.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDuration.java @@ -112,7 +112,7 @@ public class ScalarTypeDuration extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.KEYWORD; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java index ca232e718..dbf2276fd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java @@ -46,11 +46,11 @@ public class ScalarTypeEnumStandard { @Override public Set getDbCheckConstraintValues() { - LinkedHashSet values = new LinkedHashSet(); + LinkedHashSet values = new LinkedHashSet<>(); Object[] ea = enumType.getEnumConstants(); - for (int i = 0; i < ea.length; i++) { - Enum e = (Enum) ea[i]; + for (Object anEa : ea) { + Enum e = (Enum) anEa; values.add("'" + e.name() + "'"); } return values; @@ -61,8 +61,8 @@ public class ScalarTypeEnumStandard { int maxLen = 0; Object[] ea = enumType.getEnumConstants(); - for (int i = 0; i < ea.length; i++) { - Enum e = (Enum) ea[i]; + for (Object anEa : ea) { + Enum e = (Enum) anEa; maxLen = Math.max(maxLen, e.name().length()); } @@ -129,9 +129,9 @@ public class ScalarTypeEnumStandard { @Override public Set getDbCheckConstraintValues() { - LinkedHashSet values = new LinkedHashSet(); - for (int i = 0; i < enumArray.length; i++) { - Enum e = (Enum) enumArray[i]; + LinkedHashSet values = new LinkedHashSet<>(); + for (Object anEnumArray : enumArray) { + Enum e = (Enum) anEnumArray; values.add(Integer.toString(e.ordinal())); } return values; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java index eeb8ad79c..fd33c984b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java @@ -29,7 +29,7 @@ public class ScalarTypeJodaLocalTime extends ScalarTypeBase { if (value == null) { b.setNull(Types.TIME); } else { - b.setTime(new Time(value.getHourOfDay(), value.getMinuteOfHour(), value.getSecondOfMinute())); + b.setTime(new Time(value.toDateTimeToday().getMillis())); } } @@ -48,7 +48,7 @@ public class ScalarTypeJodaLocalTime extends ScalarTypeBase { public Object toJdbcType(Object value) { if (value instanceof LocalTime) { LocalTime lt = (LocalTime) value; - return new Time(lt.getHourOfDay(), lt.getMinuteOfHour(), lt.getSecondOfMinute()); + return new Time(lt.toDateTimeToday().getMillis()); } return BasicTypeConverter.toTime(value); } @@ -119,6 +119,6 @@ public class ScalarTypeJodaLocalTime extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.KEYWORD; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTime.java index 1e3d0da6f..c9fc34d57 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTime.java @@ -105,7 +105,7 @@ public class ScalarTypeLocalTime extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.KEYWORD; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDay.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDay.java index 983439a12..d8943b03e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDay.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDay.java @@ -129,7 +129,7 @@ public class ScalarTypeMonthDay extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.KEYWORD; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeString.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeString.java index 0c3b31103..1c8638404 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeString.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeString.java @@ -96,6 +96,6 @@ public class ScalarTypeString extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.TEXT; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeTime.java index 09e046062..f310e918d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeTime.java @@ -98,7 +98,7 @@ public class ScalarTypeTime extends ScalarTypeBase