From 28655a4d7f0b85cc6f12d68b5f298fde916d52fd Mon Sep 17 00:00:00 2001 From: Moritz Becker Date: Wed, 3 Aug 2016 17:21:24 +0200 Subject: [PATCH] line ending normalization --- .gitignore | 124 +-- .travis-settings.xml | 24 +- LICENSE.txt | 404 ++++----- .../persistence/BaseCTECriteriaBuilder.java | 54 +- .../persistence/BaseCriteriaBuilder.java | 54 +- .../BaseDeleteCriteriaBuilder.java | 56 +- .../BaseFinalSetOperationBuilder.java | 56 +- .../BaseInsertCriteriaBuilder.java | 68 +- .../BaseModificationCriteriaBuilder.java | 52 +- .../BaseOngoingFinalSetOperationBuilder.java | 58 +- .../BaseOngoingSetOperationBuilder.java | 70 +- .../persistence/BaseQueryBuilder.java | 72 +- .../persistence/BaseSubqueryBuilder.java | 58 +- .../java/com/blazebit/persistence/CTE.java | 24 +- .../com/blazebit/persistence/CTEBuilder.java | 116 +-- .../com/blazebit/persistence/Criteria.java | 112 +-- .../blazebit/persistence/CriteriaBuilder.java | 64 +- .../persistence/CriteriaBuilderFactory.java | 282 +++--- .../persistence/DeleteCriteriaBuilder.java | 54 +- .../blazebit/persistence/DistinctBuilder.java | 68 +- .../blazebit/persistence/EscapeBuilder.java | 86 +- .../FinalSetOperationCTECriteriaBuilder.java | 66 +- .../FinalSetOperationCriteriaBuilder.java | 54 +- .../FinalSetOperationSubqueryBuilder.java | 66 +- .../persistence/FullQueryBuilder.java | 486 +++++------ .../FullSelectCTECriteriaBuilder.java | 68 +- .../persistence/HavingAndBuilder.java | 82 +- .../blazebit/persistence/HavingOrBuilder.java | 82 +- .../persistence/InsertCriteriaBuilder.java | 54 +- .../persistence/JoinOnAndBuilder.java | 82 +- .../blazebit/persistence/JoinOnOrBuilder.java | 82 +- .../com/blazebit/persistence/JoinType.java | 76 +- .../java/com/blazebit/persistence/Keyset.java | 70 +- .../blazebit/persistence/KeysetBuilder.java | 88 +- .../com/blazebit/persistence/KeysetPage.java | 116 +-- .../persistence/KeysetQueryBuilder.java | 164 ++-- ...OngoingSetOperationCTECriteriaBuilder.java | 54 +- ...eafOngoingSetOperationCriteriaBuilder.java | 52 +- ...eafOngoingSetOperationSubqueryBuilder.java | 54 +- .../com/blazebit/persistence/LikeBuilder.java | 58 +- .../blazebit/persistence/LimitBuilder.java | 80 +- .../blazebit/persistence/ObjectBuilder.java | 104 +-- ...ngFinalSetOperationCTECriteriaBuilder.java | 54 +- ...goingFinalSetOperationCriteriaBuilder.java | 54 +- ...goingFinalSetOperationSubqueryBuilder.java | 54 +- .../OngoingSetOperationBuilder.java | 60 +- ...OngoingSetOperationCTECriteriaBuilder.java | 58 +- .../OngoingSetOperationCriteriaBuilder.java | 60 +- .../OngoingSetOperationSubqueryBuilder.java | 60 +- .../persistence/PaginatedCriteriaBuilder.java | 140 +-- .../QuantifiableBinaryPredicateBuilder.java | 88 +- .../blazebit/persistence/QueryBuilder.java | 58 +- .../com/blazebit/persistence/Queryable.java | 122 +-- .../persistence/ReturningBuilder.java | 60 +- .../ReturningDeleteCriteriaBuilder.java | 56 +- .../ReturningInsertCriteriaBuilder.java | 56 +- .../ReturningModificationCriteriaBuilder.java | 62 +- ...ingModificationCriteriaBuilderFactory.java | 160 ++-- .../persistence/ReturningObjectBuilder.java | 104 +-- .../blazebit/persistence/ReturningResult.java | 104 +-- .../ReturningUpdateCriteriaBuilder.java | 56 +- .../SelectBaseCTECriteriaBuilder.java | 56 +- .../persistence/SelectCTECriteriaBuilder.java | 66 +- .../SelectRecursiveCTECriteriaBuilder.java | 84 +- .../persistence/SetOperationBuilder.java | 224 ++--- .../StartOngoingSetOperationBuilder.java | 58 +- ...OngoingSetOperationCTECriteriaBuilder.java | 52 +- ...artOngoingSetOperationCriteriaBuilder.java | 54 +- ...artOngoingSetOperationSubqueryBuilder.java | 54 +- .../blazebit/persistence/SubqueryBuilder.java | 70 +- .../persistence/UpdateCriteriaBuilder.java | 54 +- .../blazebit/persistence/WhereAndBuilder.java | 82 +- .../blazebit/persistence/WhereOrBuilder.java | 82 +- .../persistence/internal/package-info.java | 44 +- .../blazebit/persistence/package-info.java | 42 +- .../CriteriaBuilderConfigurationProvider.java | 68 +- .../persistence/spi/CteQueryWrapper.java | 68 +- .../spi/FunctionRenderContext.java | 116 +-- .../persistence/spi/JpqlFunctionGroup.java | 100 +-- .../persistence/spi/OrderByElement.java | 66 +- .../persistence/spi/QueryTransformer.java | 80 +- .../persistence/spi/SetOperationType.java | 20 +- .../persistence/spi/TemplateRenderer.java | 332 +++---- .../persistence/spi/package-info.java | 42 +- .../AbortableOnClauseJoinNodeVisitor.java | 98 +-- .../impl/AbortableResultJoinNodeVisitor.java | 54 +- .../impl/AbstractCriteriaBuilder.java | 154 ++-- .../impl/AbstractFullQueryBuilder.java | 538 ++++++------ .../impl/AbstractQueryBuilder.java | 128 +-- .../impl/AggregateDetectionVisitor.java | 30 +- .../blazebit/persistence/impl/AliasInfo.java | 56 +- .../persistence/impl/AliasManager.java | 256 +++--- .../impl/BaseDeleteCriteriaBuilderImpl.java | 82 +- ...nalSetOperationCTECriteriaBuilderImpl.java | 174 ++-- ...eFinalSetOperationCriteriaBuilderImpl.java | 112 +-- ...eFinalSetOperationSubqueryBuilderImpl.java | 178 ++-- .../impl/BaseInsertCriteriaBuilderImpl.java | 282 +++--- .../impl/BaseSubqueryBuilderImpl.java | 204 ++--- .../impl/BuilderChainingException.java | 88 +- .../persistence/impl/BuilderListener.java | 66 +- .../persistence/impl/BuilderListenerImpl.java | 132 +-- .../persistence/impl/CTEBuilderListener.java | 60 +- .../impl/CTEBuilderListenerImpl.java | 120 +-- .../blazebit/persistence/impl/CTEInfo.java | 98 +-- .../persistence/impl/CTEInfoBuilder.java | 54 +- .../blazebit/persistence/impl/CTEManager.java | 304 +++---- ...teriaBuilderConfigurationProviderImpl.java | 86 +- .../persistence/impl/CriteriaBuilderImpl.java | 186 ++-- .../impl/DefaultOrderByElement.java | 142 +-- .../impl/DeleteCriteriaBuilderImpl.java | 64 +- .../impl/EntitySelectResolveVisitor.java | 212 ++--- .../impl/ExpressionTransformer.java | 58 +- .../ExternalAliasDereferencingException.java | 82 +- ...nalSetOperationCTECriteriaBuilderImpl.java | 80 +- .../FinalSetOperationCriteriaBuilderImpl.java | 66 +- .../FinalSetOperationSubqueryBuilderImpl.java | 80 +- .../FullSelectCTECriteriaBuilderImpl.java | 110 +-- .../impl/IllegalSubqueryDetector.java | 144 ++-- .../impl/InsertCriteriaBuilderImpl.java | 64 +- .../persistence/impl/JoinAliasInfo.java | 154 ++-- .../persistence/impl/JoinNodeVisitor.java | 54 +- .../persistence/impl/JoinTreeNode.java | 194 ++--- .../persistence/impl/JoinVisitor.java | 268 +++--- ...ingSetOperationCTECriteriaBuilderImpl.java | 126 +-- ...ngoingSetOperationCriteriaBuilderImpl.java | 126 +-- ...ngoingSetOperationSubqueryBuilderImpl.java | 128 +-- .../impl/OnClauseJoinNodeVisitor.java | 80 +- ...nalSetOperationCTECriteriaBuilderImpl.java | 66 +- ...gFinalSetOperationCriteriaBuilderImpl.java | 66 +- ...gFinalSetOperationSubqueryBuilderImpl.java | 66 +- ...ingSetOperationCTECriteriaBuilderImpl.java | 166 ++-- ...ngoingSetOperationCriteriaBuilderImpl.java | 146 ++-- ...ngoingSetOperationSubqueryBuilderImpl.java | 148 ++-- .../persistence/impl/OrderByExpression.java | 190 ++-- .../persistence/impl/PagedListImpl.java | 192 ++--- .../impl/ParameterRegistrationVisitor.java | 86 +- ...dicateAndSubqueryBuilderEndedListener.java | 132 +-- .../impl/QueryToTypedQueryAdapter.java | 386 ++++----- .../impl/RecursiveCTECriteriaBuilderImpl.java | 138 +-- .../impl/ResultJoinNodeVisitor.java | 54 +- .../ReturningDeleteCriteriaBuilderImpl.java | 76 +- .../ReturningInsertCriteriaBuilderImpl.java | 76 +- ...ModificationCriteraBuilderFactoryImpl.java | 152 ++-- .../ReturningUpdateCriteriaBuilderImpl.java | 76 +- .../impl/SelectCTECriteriaBuilderImpl.java | 92 +- .../blazebit/persistence/impl/SelectInfo.java | 104 +-- .../impl/SelectInfoTransformer.java | 52 +- .../persistence/impl/SelectInfoVisitor.java | 52 +- .../SelectObjectBuilderEndedListener.java | 74 +- .../persistence/impl/SetOperationInfo.java | 26 +- .../persistence/impl/SetOperationManager.java | 150 ++-- .../SubqueryAndExpressionBuilderListener.java | 136 +-- .../persistence/impl/SubqueryBuilderImpl.java | 160 ++-- .../impl/SubqueryBuilderListener.java | 70 +- .../impl/SubqueryBuilderListenerImpl.java | 158 ++-- .../impl/SubqueryInitiatorFactory.java | 80 +- .../impl/SubqueryInternalBuilder.java | 76 +- ...ubqueryRecursiveExpressionTransformer.java | 82 +- .../impl/UpdateCriteriaBuilderImpl.java | 64 +- .../blazebit/persistence/impl/Version.java | 60 +- .../builder/expression/EscapeBuilderImpl.java | 158 ++-- .../builder/expression/ExpressionBuilder.java | 56 +- .../ExpressionBuilderEndedListener.java | 54 +- .../ExpressionBuilderEndedListenerImpl.java | 106 +-- .../expression/SimpleCaseWhenBuilderImpl.java | 142 +-- .../builder/object/ClassObjectBuilder.java | 174 ++-- .../object/ConstructorObjectBuilder.java | 118 +-- ...legatingKeysetExtractionObjectBuilder.java | 104 +-- .../object/KeysetExtractionObjectBuilder.java | 162 ++-- .../object/ReturningTupleObjectBuilder.java | 294 +++---- .../CaseExpressionBuilderListener.java | 80 +- .../builder/predicate/EqPredicateBuilder.java | 84 +- .../builder/predicate/GePredicateBuilder.java | 84 +- .../builder/predicate/GtPredicateBuilder.java | 84 +- .../builder/predicate/LePredicateBuilder.java | 84 +- .../LeftHandsideSubqueryPredicateBuilder.java | 58 +- ...dsideSubqueryPredicateBuilderListener.java | 70 +- .../builder/predicate/LtPredicateBuilder.java | 84 +- .../PredicateBuilderEndedListener.java | 58 +- .../PredicateBuilderEndedListenerImpl.java | 108 +-- ...nLeftHandsideSubqueryPredicateBuilder.java | 78 +- .../impl/dialect/MySQLDbmsDialect.java | 154 ++-- .../impl/dialect/PostgreSQLDbmsDialect.java | 336 ++++---- .../impl/function/CyclicUnsignedCounter.java | 46 +- .../function/datediff/DateDiffFunction.java | 126 +-- .../datediff/day/AccessDayDiffFunction.java | 70 +- .../datediff/day/DayDiffFunction.java | 60 +- .../datediff/day/DefaultDayDiffFunction.java | 70 +- .../datediff/day/MySQLDayDiffFunction.java | 70 +- .../datediff/hour/AccessHourDiffFunction.java | 68 +- .../hour/DefaultHourDiffFunction.java | 70 +- .../datediff/hour/HourDiffFunction.java | 60 +- .../datediff/hour/MySQLHourDiffFunction.java | 70 +- .../minute/AccessMinuteDiffFunction.java | 68 +- .../minute/DefaultMinuteDiffFunction.java | 70 +- .../datediff/minute/MinuteDiffFunction.java | 58 +- .../minute/MySQLMinuteDiffFunction.java | 70 +- .../month/AccessMonthDiffFunction.java | 68 +- .../month/DefaultMonthDiffFunction.java | 70 +- .../datediff/month/MonthDiffFunction.java | 58 +- .../month/MySQLMonthDiffFunction.java | 70 +- .../second/AccessSecondDiffFunction.java | 68 +- .../second/DefaultSecondDiffFunction.java | 70 +- .../second/MySQLSecondDiffFunction.java | 70 +- .../datediff/second/SecondDiffFunction.java | 58 +- .../datediff/year/AccessYearDiffFunction.java | 68 +- .../year/DefaultYearDiffFunction.java | 70 +- .../datediff/year/MySQLYearDiffFunction.java | 70 +- .../year/PostgreSQLYearDiffFunction.java | 70 +- .../datediff/year/YearDiffFunction.java | 58 +- .../datetime/day/AccessDayFunction.java | 56 +- .../function/datetime/day/DB2DayFunction.java | 56 +- .../function/datetime/day/DayFunction.java | 124 +-- .../datetime/day/DerbyDayFunction.java | 56 +- .../datetime/day/SQLServerDayFunction.java | 56 +- .../datetime/day/SqliteDayFunction.java | 56 +- .../datetime/day/SybaseDayFunction.java | 56 +- .../datetime/hour/AccessHourFunction.java | 56 +- .../datetime/hour/DB2HourFunction.java | 56 +- .../datetime/hour/DerbyHourFunction.java | 56 +- .../function/datetime/hour/HourFunction.java | 124 +-- .../datetime/hour/SQLServerHourFunction.java | 56 +- .../datetime/hour/SqliteHourFunction.java | 56 +- .../datetime/hour/SybaseHourFunction.java | 56 +- .../datetime/minute/AccessMinuteFunction.java | 56 +- .../datetime/minute/DB2MinuteFunction.java | 56 +- .../datetime/minute/DerbyMinuteFunction.java | 56 +- .../datetime/minute/MinuteFunction.java | 124 +-- .../minute/SQLServerMinuteFunction.java | 56 +- .../datetime/minute/SqliteMinuteFunction.java | 56 +- .../datetime/minute/SybaseMinuteFunction.java | 56 +- .../datetime/month/AccessMonthFunction.java | 56 +- .../datetime/month/DB2MonthFunction.java | 56 +- .../datetime/month/DerbyMonthFunction.java | 56 +- .../datetime/month/MonthFunction.java | 124 +-- .../month/SQLServerMonthFunction.java | 56 +- .../datetime/month/SqliteMonthFunction.java | 56 +- .../datetime/month/SybaseMonthFunction.java | 56 +- .../datetime/second/AccessSecondFunction.java | 56 +- .../datetime/second/DB2SecondFunction.java | 56 +- .../datetime/second/DerbySecondFunction.java | 56 +- .../second/SQLServerSecondFunction.java | 56 +- .../datetime/second/SecondFunction.java | 124 +-- .../datetime/second/SqliteSecondFunction.java | 56 +- .../datetime/second/SybaseSecondFunction.java | 56 +- .../datetime/year/AccessYearFunction.java | 56 +- .../datetime/year/DB2YearFunction.java | 56 +- .../datetime/year/DerbyYearFunction.java | 56 +- .../datetime/year/SQLServerYearFunction.java | 56 +- .../datetime/year/SqliteYearFunction.java | 56 +- .../datetime/year/SybaseYearFunction.java | 56 +- .../function/datetime/year/YearFunction.java | 124 +-- .../impl/function/limit/LimitFunction.java | 184 ++-- .../MySQLPagePositionFunction.java | 58 +- .../OraclePagePositionFunction.java | 60 +- .../pageposition/PagePositionFunction.java | 196 ++--- .../TransactSQLPagePositionFunction.java | 60 +- .../impl/function/set/SetFunction.java | 204 ++--- .../jpaprovider/HibernateJpa21Provider.java | 82 +- .../impl/jpaprovider/JpaProviders.java | 156 ++-- .../AbstractKeysetBuilderEndedListener.java | 142 +-- .../impl/keyset/AbstractKeysetLink.java | 126 +-- .../keyset/KeysetBuilderEndedListener.java | 52 +- .../impl/keyset/KeysetBuilderImpl.java | 124 +-- .../persistence/impl/keyset/KeysetImpl.java | 130 +-- .../persistence/impl/keyset/KeysetLink.java | 72 +- .../impl/keyset/KeysetManager.java | 358 ++++---- .../persistence/impl/keyset/KeysetMode.java | 58 +- .../impl/keyset/KeysetPageImpl.java | 134 +-- .../impl/keyset/KeysetPaginationHelper.java | 168 ++-- .../impl/keyset/LazyKeysetLink.java | 148 ++-- .../impl/keyset/SimpleKeysetLink.java | 104 +-- ...e.spi.CriteriaBuilderConfigurationProvider | 2 +- .../impl/expression/AbstractExpression.java | 76 +- .../impl/expression/ArrayExpression.java | 166 ++-- .../impl/expression/CompositeExpression.java | 264 +++--- .../expression/ExpressionFactoryImpl.java | 98 +-- .../impl/expression/FooExpression.java | 166 ++-- .../impl/expression/FunctionExpression.java | 190 ++-- .../expression/GeneralCaseExpression.java | 202 ++--- .../impl/expression/LiteralExpression.java | 184 ++-- .../impl/expression/NullExpression.java | 110 +-- .../impl/expression/ParameterExpression.java | 184 ++-- .../expression/PathElementExpression.java | 54 +- .../impl/expression/PathExpression.java | 318 +++---- .../impl/expression/PathReference.java | 32 +- .../impl/expression/PropertyExpression.java | 158 ++-- .../SimpleCachingExpressionFactory.java | 204 ++--- .../impl/expression/SimpleCaseExpression.java | 196 ++--- .../impl/expression/SimplePathReference.java | 110 +-- .../persistence/impl/expression/Subquery.java | 58 +- .../impl/expression/SubqueryExpression.java | 144 ++-- .../expression/SubqueryExpressionFactory.java | 188 ++-- .../impl/expression/SyntaxErrorException.java | 76 +- .../impl/expression/WhenClauseExpression.java | 172 ++-- .../impl/predicate/BetweenPredicate.java | 256 +++--- .../predicate/BinaryExpressionPredicate.java | 162 ++-- .../impl/predicate/EqPredicate.java | 192 ++--- .../impl/predicate/ExistsPredicate.java | 110 +-- .../impl/predicate/GePredicate.java | 106 +-- .../impl/predicate/GtPredicate.java | 106 +-- .../impl/predicate/InPredicate.java | 100 +-- .../impl/predicate/IsEmptyPredicate.java | 102 +-- .../impl/predicate/IsNullPredicate.java | 102 +-- .../impl/predicate/LePredicate.java | 106 +-- .../impl/predicate/LikePredicate.java | 186 ++-- .../impl/predicate/LtPredicate.java | 106 +-- .../impl/predicate/MemberOfPredicate.java | 102 +-- .../persistence/impl/predicate/Negatable.java | 56 +- .../NegatableBinaryExpressionPredicate.java | 102 +-- .../impl/predicate/PredicateQuantifier.java | 58 +- ...QuantifiableBinaryExpressionPredicate.java | 154 ++-- .../predicate/UnaryExpressionPredicate.java | 166 ++-- ...e.spi.CriteriaBuilderConfigurationProvider | 2 +- .../AbstractTestExpressionFactory.java | 108 +-- .../impl/expression/SetDelegate.java | 126 +-- .../src/test/resources/logging.properties | 44 +- core/testsuite/log4j.properties | 38 +- .../src/test/resources/logging.properties | 56 +- .../manual/en_US/05_predicate_builder.adoc | 6 +- .../core/manual/en_US/06_where_clause.adoc | 6 +- .../en_US/07_group_by_having_clause.adoc | 14 +- .../core/manual/en_US/08_order_by_clause.adoc | 10 +- .../core/manual/en_US/09_select_clause.adoc | 78 +- .../core/manual/en_US/10_pagination.adoc | 36 +- documentation/src/main/style/css/style.css | 812 +++++++++--------- .../src/main/style/images/icons/README | 10 +- 327 files changed, 16859 insertions(+), 16859 deletions(-) diff --git a/.gitignore b/.gitignore index a57e8d3e41..460c5c3f51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,63 +1,63 @@ -.idea/ -*.iml -.project -.settings/ -.classpath -.factorypath -target/ -core/.project -core/.settings/ -core/.classpath -core/.factorypath -core/target/ -core/api/.project -core/api/.settings/ -core/api/.classpath -core/api/.factorypath -core/api/target/ -core/impl/.project -core/impl/.settings/ -core/impl/.classpath -core/impl/.factorypath -core/impl/target/ -core/spi/.project -core/spi/.settings/ -core/spi/.classpath -core/spi/.factorypath -core/spi/target/ -core/testsuite/.project -core/testsuite/.settings/ -core/testsuite/.classpath -core/testsuite/.factorypath -core/testsuite/target/ -entity-view/.project -entity-view/.settings/ -entity-view/.classpath -entity-view/.factorypath -entity-view/target/ -entity-view/api/.project -entity-view/api/.settings/ -entity-view/api/.classpath -entity-view/api/.factorypath -entity-view/api/target/ -entity-view/impl/.project -entity-view/impl/.settings/ -entity-view/impl/.classpath -entity-view/impl/.factorypath -entity-view/impl/target/ -entity-view/testsuite/.project -entity-view/testsuite/.settings/ -entity-view/testsuite/.classpath -entity-view/testsuite/.factorypath -entity-view/testsuite/target/ -integration/.project -integration/.settings/ -integration/.classpath -integration/.factorypath -integration/target/ -integration/hibernate/.project -integration/hibernate/.settings/ -integration/hibernate/.classpath -integration/hibernate/.factorypath -integration/hibernate/target/ +.idea/ +*.iml +.project +.settings/ +.classpath +.factorypath +target/ +core/.project +core/.settings/ +core/.classpath +core/.factorypath +core/target/ +core/api/.project +core/api/.settings/ +core/api/.classpath +core/api/.factorypath +core/api/target/ +core/impl/.project +core/impl/.settings/ +core/impl/.classpath +core/impl/.factorypath +core/impl/target/ +core/spi/.project +core/spi/.settings/ +core/spi/.classpath +core/spi/.factorypath +core/spi/target/ +core/testsuite/.project +core/testsuite/.settings/ +core/testsuite/.classpath +core/testsuite/.factorypath +core/testsuite/target/ +entity-view/.project +entity-view/.settings/ +entity-view/.classpath +entity-view/.factorypath +entity-view/target/ +entity-view/api/.project +entity-view/api/.settings/ +entity-view/api/.classpath +entity-view/api/.factorypath +entity-view/api/target/ +entity-view/impl/.project +entity-view/impl/.settings/ +entity-view/impl/.classpath +entity-view/impl/.factorypath +entity-view/impl/target/ +entity-view/testsuite/.project +entity-view/testsuite/.settings/ +entity-view/testsuite/.classpath +entity-view/testsuite/.factorypath +entity-view/testsuite/target/ +integration/.project +integration/.settings/ +integration/.classpath +integration/.factorypath +integration/target/ +integration/hibernate/.project +integration/hibernate/.settings/ +integration/hibernate/.classpath +integration/hibernate/.factorypath +integration/hibernate/target/ /core/impl/nbactions.xml \ No newline at end of file diff --git a/.travis-settings.xml b/.travis-settings.xml index 43bdba0f43..43e2471062 100644 --- a/.travis-settings.xml +++ b/.travis-settings.xml @@ -1,12 +1,12 @@ - - - - - sonatype-nexus-snapshots - ${env.SONATYPE_USERNAME} - ${env.SONATYPE_PASSWORD} - - - - + + + + + sonatype-nexus-snapshots + ${env.SONATYPE_USERNAME} + ${env.SONATYPE_PASSWORD} + + + + diff --git a/LICENSE.txt b/LICENSE.txt index 75b52484ea..d645695673 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseCTECriteriaBuilder.java index 88ec7929fa..6f43dea4c9 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseCTECriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for cte criteria queries. This is the entry point for building cte queries. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BaseCTECriteriaBuilder> extends CommonQueryBuilder, FromBuilder, KeysetQueryBuilder, WhereBuilder, OrderByBuilder, GroupByBuilder, DistinctBuilder, LimitBuilder { -// TODO: maybe also add CTEBuilder? -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for cte criteria queries. This is the entry point for building cte queries. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BaseCTECriteriaBuilder> extends CommonQueryBuilder, FromBuilder, KeysetQueryBuilder, WhereBuilder, OrderByBuilder, GroupByBuilder, DistinctBuilder, LimitBuilder { +// TODO: maybe also add CTEBuilder? +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseCriteriaBuilder.java index a43de289c7..289fa1c39e 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseCriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for criteria queries. This is the entry point for building queries. - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BaseCriteriaBuilder> extends BaseQueryBuilder, GroupByBuilder, DistinctBuilder, LimitBuilder, CTEBuilder { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for criteria queries. This is the entry point for building queries. + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BaseCriteriaBuilder> extends BaseQueryBuilder, GroupByBuilder, DistinctBuilder, LimitBuilder, CTEBuilder { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseDeleteCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseDeleteCriteriaBuilder.java index 4e323acf76..0d81fa1b23 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseDeleteCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseDeleteCriteriaBuilder.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for delete queries. - * - * @param The entity type for which this delete query is - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BaseDeleteCriteriaBuilder> extends BaseModificationCriteriaBuilder { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for delete queries. + * + * @param The entity type for which this delete query is + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BaseDeleteCriteriaBuilder> extends BaseModificationCriteriaBuilder { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseFinalSetOperationBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseFinalSetOperationBuilder.java index 3b0c91b575..ebfbeacd73 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseFinalSetOperationBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseFinalSetOperationBuilder.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The builder result type - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BaseFinalSetOperationBuilder> extends OrderByBuilder, LimitBuilder { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The builder result type + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BaseFinalSetOperationBuilder> extends OrderByBuilder, LimitBuilder { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseInsertCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseInsertCriteriaBuilder.java index ba783f6f86..6b0df0b992 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseInsertCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseInsertCriteriaBuilder.java @@ -1,34 +1,34 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A base builder for insert queries. - * - * @param The entity type for which this update query is - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BaseInsertCriteriaBuilder> extends BaseModificationCriteriaBuilder, FromBuilder, KeysetQueryBuilder, OrderByBuilder, GroupByBuilder, DistinctBuilder, LimitBuilder { - - // TODO: documentation - public X bind(String attribute, Object value); - - // TODO: documentation - public SelectBuilder bind(String attribute); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A base builder for insert queries. + * + * @param The entity type for which this update query is + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BaseInsertCriteriaBuilder> extends BaseModificationCriteriaBuilder, FromBuilder, KeysetQueryBuilder, OrderByBuilder, GroupByBuilder, DistinctBuilder, LimitBuilder { + + // TODO: documentation + public X bind(String attribute, Object value); + + // TODO: documentation + public SelectBuilder bind(String attribute); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseModificationCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseModificationCriteriaBuilder.java index 3c94d91172..ea21ad95a2 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseModificationCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseModificationCriteriaBuilder.java @@ -1,26 +1,26 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for modification queries. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BaseModificationCriteriaBuilder> extends WhereBuilder { -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for modification queries. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BaseModificationCriteriaBuilder> extends WhereBuilder { +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseOngoingFinalSetOperationBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseOngoingFinalSetOperationBuilder.java index a4a79170ec..e80b34ae75 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseOngoingFinalSetOperationBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseOngoingFinalSetOperationBuilder.java @@ -1,29 +1,29 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BaseOngoingFinalSetOperationBuilder> extends BaseFinalSetOperationBuilder { - - // TODO: documentation - public T endSet(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BaseOngoingFinalSetOperationBuilder> extends BaseFinalSetOperationBuilder { + + // TODO: documentation + public T endSet(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseOngoingSetOperationBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseOngoingSetOperationBuilder.java index 091b8b71ea..b0ef37ffa7 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseOngoingSetOperationBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseOngoingSetOperationBuilder.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @param The set sub-operation result type - * @param The set nesting start type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BaseOngoingSetOperationBuilder> extends SetOperationBuilder { - - /** - * Ends the current set operation scope and switches back to the parent query. - * - * @return The parent query builder - */ - public Y endSet(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @param The set sub-operation result type + * @param The set nesting start type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BaseOngoingSetOperationBuilder> extends SetOperationBuilder { + + /** + * Ends the current set operation scope and switches back to the parent query. + * + * @return The parent query builder + */ + public Y endSet(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseQueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseQueryBuilder.java index e049beb5bf..ba567a0ae7 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseQueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseQueryBuilder.java @@ -1,36 +1,36 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A base interface for builders that support basic query functionality. - * This interface is shared between normal query builders and subquery builders. - * - * @param The query result type - * @param The concrete builder type - * @author Christian Beikov - * @since 1.0 - */ -public interface BaseQueryBuilder> extends CommonQueryBuilder, FromBuilder, KeysetQueryBuilder, WhereBuilder, OrderByBuilder, SelectBuilder { - - /** - * Returns the result type of this query. - * - * @return The result type of this query - */ - public Class getResultType(); - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A base interface for builders that support basic query functionality. + * This interface is shared between normal query builders and subquery builders. + * + * @param The query result type + * @param The concrete builder type + * @author Christian Beikov + * @since 1.0 + */ +public interface BaseQueryBuilder> extends CommonQueryBuilder, FromBuilder, KeysetQueryBuilder, WhereBuilder, OrderByBuilder, SelectBuilder { + + /** + * Returns the result type of this query. + * + * @return The result type of this query + */ + public Class getResultType(); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/BaseSubqueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/BaseSubqueryBuilder.java index 44809cc915..f0fc03ef69 100644 --- a/core/api/src/main/java/com/blazebit/persistence/BaseSubqueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/BaseSubqueryBuilder.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import javax.persistence.Tuple; - -/** - * A builder for subquery criteria queries. - * - * @param The parent query builder type - * @author Christian Beikov - * @since 1.0 - */ -public interface BaseSubqueryBuilder> extends BaseQueryBuilder, GroupByBuilder, DistinctBuilder, LimitBuilder, CTEBuilder { - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import javax.persistence.Tuple; + +/** + * A builder for subquery criteria queries. + * + * @param The parent query builder type + * @author Christian Beikov + * @since 1.0 + */ +public interface BaseSubqueryBuilder> extends BaseQueryBuilder, GroupByBuilder, DistinctBuilder, LimitBuilder, CTEBuilder { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/CTE.java b/core/api/src/main/java/com/blazebit/persistence/CTE.java index 61431a099d..a9292001ba 100644 --- a/core/api/src/main/java/com/blazebit/persistence/CTE.java +++ b/core/api/src/main/java/com/blazebit/persistence/CTE.java @@ -1,12 +1,12 @@ -package com.blazebit.persistence; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) -public @interface CTE { - -} +package com.blazebit.persistence; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface CTE { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/CTEBuilder.java b/core/api/src/main/java/com/blazebit/persistence/CTEBuilder.java index bb1e90cec6..200a8f4d76 100644 --- a/core/api/src/main/java/com/blazebit/persistence/CTEBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/CTEBuilder.java @@ -1,58 +1,58 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support CTEs. - * This is related to the fact, that a query builder supports the with clause. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface CTEBuilder> { - - /** - * TODO: documentation - * - * @param cteClass - * @return - * @since 1.1.0 - */ - public FullSelectCTECriteriaBuilder with(Class cteClass); - - // TODO: documentation - public StartOngoingSetOperationCTECriteriaBuilder> withStartSet(Class cteClass); - - /** - * TODO: documentation - * - * @param cteClass - * @return - * @since 1.1.0 - */ - public SelectRecursiveCTECriteriaBuilder< T> withRecursive(Class cteClass); - - /** - * TODO: documentation - * - * @param cteClass - * @return - * @since 1.1.0 - */ - public ReturningModificationCriteriaBuilderFactory withReturning(Class cteClass); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support CTEs. + * This is related to the fact, that a query builder supports the with clause. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface CTEBuilder> { + + /** + * TODO: documentation + * + * @param cteClass + * @return + * @since 1.1.0 + */ + public FullSelectCTECriteriaBuilder with(Class cteClass); + + // TODO: documentation + public StartOngoingSetOperationCTECriteriaBuilder> withStartSet(Class cteClass); + + /** + * TODO: documentation + * + * @param cteClass + * @return + * @since 1.1.0 + */ + public SelectRecursiveCTECriteriaBuilder< T> withRecursive(Class cteClass); + + /** + * TODO: documentation + * + * @param cteClass + * @return + * @since 1.1.0 + */ + public ReturningModificationCriteriaBuilderFactory withReturning(Class cteClass); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/Criteria.java b/core/api/src/main/java/com/blazebit/persistence/Criteria.java index c9f79c8483..f3eab2482c 100644 --- a/core/api/src/main/java/com/blazebit/persistence/Criteria.java +++ b/core/api/src/main/java/com/blazebit/persistence/Criteria.java @@ -1,56 +1,56 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import com.blazebit.persistence.spi.CriteriaBuilderConfiguration; -import com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider; -import java.util.Iterator; -import java.util.ServiceLoader; - -/** - * Bootstrap class that is used to obtain a {@linkplain CriteriaBuilder} instance. - * - * @author Christian Beikov - * @since 1.0 - */ -public class Criteria { - - /** - * Returns the first {@linkplain CriteriaBuilderConfigurationProvider} that is found - * - * @return The first {@linkplain CriteriaBuilderConfigurationProvider} that is found - */ - public static CriteriaBuilderConfigurationProvider getDefaultProvider() { - ServiceLoader serviceLoader = ServiceLoader.load(CriteriaBuilderConfigurationProvider.class); - Iterator iterator = serviceLoader.iterator(); - - if (iterator.hasNext()) { - return iterator.next(); - } - - throw new IllegalStateException("No CriteriaBuilderConfigurationProvider found on the class path. Please check if a valid implementation is on the class path."); - } - - /** - * Uses the default {@linkplain CriteriaBuilderConfigurationProvider} and invokes - * {@link CriteriaBuilderConfigurationProvider#createConfiguration() }. - * - * @return A new criteria builder configuration - */ - public static CriteriaBuilderConfiguration getDefault() { - return getDefaultProvider().createConfiguration(); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import com.blazebit.persistence.spi.CriteriaBuilderConfiguration; +import com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider; +import java.util.Iterator; +import java.util.ServiceLoader; + +/** + * Bootstrap class that is used to obtain a {@linkplain CriteriaBuilder} instance. + * + * @author Christian Beikov + * @since 1.0 + */ +public class Criteria { + + /** + * Returns the first {@linkplain CriteriaBuilderConfigurationProvider} that is found + * + * @return The first {@linkplain CriteriaBuilderConfigurationProvider} that is found + */ + public static CriteriaBuilderConfigurationProvider getDefaultProvider() { + ServiceLoader serviceLoader = ServiceLoader.load(CriteriaBuilderConfigurationProvider.class); + Iterator iterator = serviceLoader.iterator(); + + if (iterator.hasNext()) { + return iterator.next(); + } + + throw new IllegalStateException("No CriteriaBuilderConfigurationProvider found on the class path. Please check if a valid implementation is on the class path."); + } + + /** + * Uses the default {@linkplain CriteriaBuilderConfigurationProvider} and invokes + * {@link CriteriaBuilderConfigurationProvider#createConfiguration() }. + * + * @return A new criteria builder configuration + */ + public static CriteriaBuilderConfiguration getDefault() { + return getDefaultProvider().createConfiguration(); + } +} diff --git a/core/api/src/main/java/com/blazebit/persistence/CriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/CriteriaBuilder.java index c88cda2860..4693d09371 100644 --- a/core/api/src/main/java/com/blazebit/persistence/CriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/CriteriaBuilder.java @@ -1,32 +1,32 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for criteria queries. This is the entry point for building queries. - * - * @param The query result type - * @author Christian Beikov - * @since 1.0 - */ -public interface CriteriaBuilder extends FullQueryBuilder>, BaseCriteriaBuilder>, SetOperationBuilder, StartOngoingSetOperationCriteriaBuilder>> { - - @Override - public SelectObjectBuilder> selectNew(Class clazz); - - @Override - public CriteriaBuilder selectNew(ObjectBuilder builder); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for criteria queries. This is the entry point for building queries. + * + * @param The query result type + * @author Christian Beikov + * @since 1.0 + */ +public interface CriteriaBuilder extends FullQueryBuilder>, BaseCriteriaBuilder>, SetOperationBuilder, StartOngoingSetOperationCriteriaBuilder>> { + + @Override + public SelectObjectBuilder> selectNew(Class clazz); + + @Override + public CriteriaBuilder selectNew(ObjectBuilder builder); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/CriteriaBuilderFactory.java b/core/api/src/main/java/com/blazebit/persistence/CriteriaBuilderFactory.java index b886f3930c..564003ea12 100644 --- a/core/api/src/main/java/com/blazebit/persistence/CriteriaBuilderFactory.java +++ b/core/api/src/main/java/com/blazebit/persistence/CriteriaBuilderFactory.java @@ -1,141 +1,141 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.util.Map; - -import javax.persistence.EntityManager; - -/** - * An interface used to create criteria builders. - * - * @author Christian Beikov - * @since 1.0 - */ -public interface CriteriaBuilderFactory { - - // TODO: documentation - public StartOngoingSetOperationCriteriaBuilder> startSet(EntityManager entityManager, Class resultClass); - - /** - * Like {@link CriteriaBuilderFactory#create(javax.persistence.EntityManager, java.lang.Class, java.lang.String)} but with the alias - * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the result class returns. - * - * @param entityManager The entity manager to use for the criteria builder - * @param resultClass The result class of the query - * @param The type of the result class - * @return A new criteria builder - */ - public CriteriaBuilder create(EntityManager entityManager, Class resultClass); - - /** - * Creates a new criteria builder with the given result class. The result class will be used as default from class. - * The alias will be used as default alias for the from class. Both can be overridden by invoking - * {@link BaseQueryBuilder#from(java.lang.Class, java.lang.String)}. - * - * @param entityManager The entity manager to use for the criteria builder - * @param resultClass The result class of the query - * @param The type of the result class - * @param alias The alias that should be used for the result class from clause - * @return A new criteria builder - */ - public CriteriaBuilder create(EntityManager entityManager, Class resultClass, String alias); - - /** - * Like {@link CriteriaBuilderFactory#delete(javax.persistence.EntityManager, java.lang.Class, java.lang.String)} but with the alias - * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the delete class returns. - * - * @param entityManager The entity manager to use for the delete criteria builder - * @param deleteClass The entity class for the delete criteria - * @param The type of the entity for the delete criteria - * @return A new delete criteria builder - * @since 1.1.0 - */ - public DeleteCriteriaBuilder delete(EntityManager entityManager, Class deleteClass); - - /** - * Creates a new delete criteria builder for the given entity class. - * - * @param entityManager The entity manager to use for the delete criteria builder - * @param deleteClass The entity class for the delete criteria - * @param alias The alias that should be used for the entity - * @param The type of the entity for the delete criteria - * @return A new delete criteria builder - * @since 1.1.0 - */ - public DeleteCriteriaBuilder delete(EntityManager entityManager, Class deleteClass, String alias); - - /** - * Like {@link CriteriaBuilderFactory#update(javax.persistence.EntityManager, java.lang.Class, java.lang.String)} but with the alias - * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the update class returns. - * - * @param entityManager The entity manager to use for the update criteria builder - * @param updateClass The entity class for the update criteria - * @param The type of the entity for the update criteria - * @return A new update criteria builder - * @since 1.1.0 - */ - public UpdateCriteriaBuilder update(EntityManager entityManager, Class updateClass); - - /** - * Creates a new update criteria builder for the given entity class. - * - * @param entityManager The entity manager to use for the update criteria builder - * @param updateClass The entity class for the update criteria - * @param alias The alias that should be used for the entity - * @param The type of the entity for the update criteria - * @return A new update criteria builder - * @since 1.1.0 - */ - public UpdateCriteriaBuilder update(EntityManager entityManager, Class updateClass, String alias); - - /** - * Creates a new insert criteria builder for the given entity class. - * - * @param entityManager The entity manager to use for the insert criteria builder - * @param insertClass The entity class for the insert criteria - * @param The type of the entity for the insert criteria - * @return A new insert criteria builder - * @since 1.1.0 - */ - public InsertCriteriaBuilder insert(EntityManager entityManager, Class insertClass); - - /** - * Returns the service provided by this criteria builder factory or null if none is available. - * - * @param serviceClass The type of the service - * @return The service or null - * @since 1.0.5 - */ - public T getService(Class serviceClass); - - /** - * Returns all properties. - * - * @return All properties - * @since 1.1.0 - */ - public Map getProperties(); - - /** - * Returns a property value by name. - * - * @param propertyName The name of the property - * @return The value currently associated with that property name; may be null. - * @since 1.1.0 - */ - public String getProperty(String propertyName); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.util.Map; + +import javax.persistence.EntityManager; + +/** + * An interface used to create criteria builders. + * + * @author Christian Beikov + * @since 1.0 + */ +public interface CriteriaBuilderFactory { + + // TODO: documentation + public StartOngoingSetOperationCriteriaBuilder> startSet(EntityManager entityManager, Class resultClass); + + /** + * Like {@link CriteriaBuilderFactory#create(javax.persistence.EntityManager, java.lang.Class, java.lang.String)} but with the alias + * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the result class returns. + * + * @param entityManager The entity manager to use for the criteria builder + * @param resultClass The result class of the query + * @param The type of the result class + * @return A new criteria builder + */ + public CriteriaBuilder create(EntityManager entityManager, Class resultClass); + + /** + * Creates a new criteria builder with the given result class. The result class will be used as default from class. + * The alias will be used as default alias for the from class. Both can be overridden by invoking + * {@link BaseQueryBuilder#from(java.lang.Class, java.lang.String)}. + * + * @param entityManager The entity manager to use for the criteria builder + * @param resultClass The result class of the query + * @param The type of the result class + * @param alias The alias that should be used for the result class from clause + * @return A new criteria builder + */ + public CriteriaBuilder create(EntityManager entityManager, Class resultClass, String alias); + + /** + * Like {@link CriteriaBuilderFactory#delete(javax.persistence.EntityManager, java.lang.Class, java.lang.String)} but with the alias + * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the delete class returns. + * + * @param entityManager The entity manager to use for the delete criteria builder + * @param deleteClass The entity class for the delete criteria + * @param The type of the entity for the delete criteria + * @return A new delete criteria builder + * @since 1.1.0 + */ + public DeleteCriteriaBuilder delete(EntityManager entityManager, Class deleteClass); + + /** + * Creates a new delete criteria builder for the given entity class. + * + * @param entityManager The entity manager to use for the delete criteria builder + * @param deleteClass The entity class for the delete criteria + * @param alias The alias that should be used for the entity + * @param The type of the entity for the delete criteria + * @return A new delete criteria builder + * @since 1.1.0 + */ + public DeleteCriteriaBuilder delete(EntityManager entityManager, Class deleteClass, String alias); + + /** + * Like {@link CriteriaBuilderFactory#update(javax.persistence.EntityManager, java.lang.Class, java.lang.String)} but with the alias + * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the update class returns. + * + * @param entityManager The entity manager to use for the update criteria builder + * @param updateClass The entity class for the update criteria + * @param The type of the entity for the update criteria + * @return A new update criteria builder + * @since 1.1.0 + */ + public UpdateCriteriaBuilder update(EntityManager entityManager, Class updateClass); + + /** + * Creates a new update criteria builder for the given entity class. + * + * @param entityManager The entity manager to use for the update criteria builder + * @param updateClass The entity class for the update criteria + * @param alias The alias that should be used for the entity + * @param The type of the entity for the update criteria + * @return A new update criteria builder + * @since 1.1.0 + */ + public UpdateCriteriaBuilder update(EntityManager entityManager, Class updateClass, String alias); + + /** + * Creates a new insert criteria builder for the given entity class. + * + * @param entityManager The entity manager to use for the insert criteria builder + * @param insertClass The entity class for the insert criteria + * @param The type of the entity for the insert criteria + * @return A new insert criteria builder + * @since 1.1.0 + */ + public InsertCriteriaBuilder insert(EntityManager entityManager, Class insertClass); + + /** + * Returns the service provided by this criteria builder factory or null if none is available. + * + * @param serviceClass The type of the service + * @return The service or null + * @since 1.0.5 + */ + public T getService(Class serviceClass); + + /** + * Returns all properties. + * + * @return All properties + * @since 1.1.0 + */ + public Map getProperties(); + + /** + * Returns a property value by name. + * + * @param propertyName The name of the property + * @return The value currently associated with that property name; may be null. + * @since 1.1.0 + */ + public String getProperty(String propertyName); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/DeleteCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/DeleteCriteriaBuilder.java index 7e210b48f1..011012f954 100644 --- a/core/api/src/main/java/com/blazebit/persistence/DeleteCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/DeleteCriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for delete queries. - * - * @param The entity type for which this delete query is - * @author Christian Beikov - * @since 1.1.0 - */ -public interface DeleteCriteriaBuilder extends ModificationCriteriaBuilder>, BaseDeleteCriteriaBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for delete queries. + * + * @param The entity type for which this delete query is + * @author Christian Beikov + * @since 1.1.0 + */ +public interface DeleteCriteriaBuilder extends ModificationCriteriaBuilder>, BaseDeleteCriteriaBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/DistinctBuilder.java b/core/api/src/main/java/com/blazebit/persistence/DistinctBuilder.java index a174480b47..3c98882efe 100644 --- a/core/api/src/main/java/com/blazebit/persistence/DistinctBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/DistinctBuilder.java @@ -1,34 +1,34 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support distinct. - * This is related to the fact, that a query builder supports distinct selects. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.0 - */ -public interface DistinctBuilder> { - - /** - * Marks the query to do a distinct select. - * - * @return The query builder for chaining calls - */ - public X distinct(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support distinct. + * This is related to the fact, that a query builder supports distinct selects. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.0 + */ +public interface DistinctBuilder> { + + /** + * Marks the query to do a distinct select. + * + * @return The query builder for chaining calls + */ + public X distinct(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/EscapeBuilder.java b/core/api/src/main/java/com/blazebit/persistence/EscapeBuilder.java index e2c2a2bcb9..1d440b6c57 100644 --- a/core/api/src/main/java/com/blazebit/persistence/EscapeBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/EscapeBuilder.java @@ -1,43 +1,43 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence; - -/** - * A builder for the escape part of a like predicate. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public interface EscapeBuilder { - - /** - * Sets the given character as the escape character. - * - * @param c The escape character - * @return The parent builder - */ - public T escape(char c); - - /** - * Specifies that no escape character should be used. - * - * @return The parent builder - */ - public T noEscape(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence; + +/** + * A builder for the escape part of a like predicate. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public interface EscapeBuilder { + + /** + * Sets the given character as the escape character. + * + * @param c The escape character + * @return The parent builder + */ + public T escape(char c); + + /** + * Specifies that no escape character should be used. + * + * @return The parent builder + */ + public T noEscape(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationCTECriteriaBuilder.java index 876294d324..3981960fe2 100644 --- a/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationCTECriteriaBuilder.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The builder result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface FinalSetOperationCTECriteriaBuilder extends BaseFinalSetOperationBuilder> { - - /** - * Finishes the CTE builder. - * - * @return The parent query builder - */ - public T end(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The builder result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface FinalSetOperationCTECriteriaBuilder extends BaseFinalSetOperationBuilder> { + + /** + * Finishes the CTE builder. + * + * @return The parent query builder + */ + public T end(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationCriteriaBuilder.java index 3563f574df..240b3d9d47 100644 --- a/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationCriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The builder result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface FinalSetOperationCriteriaBuilder extends Queryable>, BaseFinalSetOperationBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The builder result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface FinalSetOperationCriteriaBuilder extends Queryable>, BaseFinalSetOperationBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationSubqueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationSubqueryBuilder.java index 4156bdaa72..a4f22866c1 100644 --- a/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationSubqueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/FinalSetOperationSubqueryBuilder.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The result type which is returned after the subquery builder - * @author Christian Beikov - * @since 1.1.0 - */ -public interface FinalSetOperationSubqueryBuilder extends BaseFinalSetOperationBuilder> { - - /** - * Finishes the CTE builder. - * - * @return The parent query builder - */ - public T end(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The result type which is returned after the subquery builder + * @author Christian Beikov + * @since 1.1.0 + */ +public interface FinalSetOperationSubqueryBuilder extends BaseFinalSetOperationBuilder> { + + /** + * Finishes the CTE builder. + * + * @return The parent query builder + */ + public T end(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/FullQueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/FullQueryBuilder.java index 1a836056d3..982e2d1907 100644 --- a/core/api/src/main/java/com/blazebit/persistence/FullQueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/FullQueryBuilder.java @@ -1,243 +1,243 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.lang.reflect.Constructor; - -/** - * A base interface for builders that support normal query functionality. - * This interface is shared between the criteria builder and paginated criteria builder. - * - * @param The query result type - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface FullQueryBuilder> extends QueryBuilder { - - /** - * Paginates the results of this query. - * - *

- * Please note: The pagination only works on entity level and NOT on row level. This means that for queries which yield multiple - * result set rows per entity (i.e. rows with the same entity id), the multiple rows are treated as 1 page entry during the - * pagination process. Hence, the result size of such paginated queries might be greater than the specified page size. - *

- * - *

- * An example for such queries would be a query that joins a collection: SELECT d.id, contacts.name FROM Document d LEFT JOIN - * d.contacts contacts If one Document has associated multiple contacts, the above query will produce multiple result set rows for - * this document. - *

- * - *

- * Since the pagination works on entity id level, the results are implicitely grouped by id and distinct. Therefore calling - * distinct() or groupBy() on a PaginatedCriteriaBuilder is not allowed. - *

- * - * @param firstResult The position of the first result to retrieve, numbered from 0 - * @param maxResults The maximum number of results to retrieve - * @return This query builder as paginated query builder - */ - public PaginatedCriteriaBuilder page(int firstResult, int maxResults); - - /** - * Paginates the results of this query and navigates to the page on which - * the entity with the given entity id is located. - * - * Beware that the same limitations like for {@link FullQueryBuilder#page(int, int)} apply. - * If the entity with the given entity id does not exist in the result list: - *
    - *
  • The result of {@link PaginatedCriteriaBuilder#getResultList()} will contain the first page
  • - *
  • {@link PagedList#getFirstResult()} will return -1
  • - *
- * - * @param entityId The id of the entity which should be located on the page - * @param maxResults The maximum number of results to retrieve - * @return This query builder as paginated query builder - */ - public PaginatedCriteriaBuilder page(Object entityId, int maxResults); - - /** - * Like {@link FullQueryBuilder#page(int, int)} but additionally uses key set pagination when possible. - * - * Beware that keyset pagination should not be used as a direct replacement for offset pagination. - * Since entries that have a lower rank than some keyset might be added or removed, the calculations - * for the firstResult might be wrong. If strict pagination is required, then a keyset should - * be thrown away when the count of lower ranked items changes to make use of offset pagination again. - * - *

- * Key set pagination is possible if and only if the following conditions are met: - *

    - *
  • This keyset reference values fit the order by expressions of this query builder AND
  • - * - *
  • {@link KeysetPage#getMaxResults()} and maxResults evaluate to the same value AND
  • - *
  • One of the following conditions is met: - *
      - *
    • The absolute value of {@link KeysetPage#getFirstResult()} - firstResult is 0
    • - *
    • The absolute value of {@link KeysetPage#getFirstResult()} - firstResult is equal to the value of - * maxResults
    • - *
    - *
  • - *
- *

- * - * @param keysetPage The key set from a previous result, may be null - * @param firstResult The position of the first result to retrieve, numbered from 0 - * @param maxResults The maximum number of results to retrieve - * @return This query builder as paginated query builder - * @see PagedList#getKeysetPage() - */ - public PaginatedCriteriaBuilder page(KeysetPage keysetPage, int firstResult, int maxResults); - - /* - * Join methods - */ - /** - * Adds a join to the query, possibly specializing implicit joins, and giving the joined element an alias. - * If fetch is set to true, a join fetch will be added. - * - * @param path The path to join - * @param alias The alias for the joined element - * @param type The join type - * @param fetch True if a join fetch should be added - * @return The query builder for chaining calls - */ - public X join(String path, String alias, JoinType type, boolean fetch); - - /** - * Adds a join to the query, possibly specializing implicit joins, and giving the joined element an alias. - * The resulting join will be the default join meaning that expressions which use the absolute path will refer to this join. - * If fetch is set to true, a join fetch will be added. - * - * @param path The path to join - * @param alias The alias for the joined element - * @param type The join type - * @param fetch True if a join fetch should be added - * @return The query builder for chaining calls - */ - public X joinDefault(String path, String alias, JoinType type, boolean fetch); - - /** - * Adds an implicit join fetch to the query. - * - * @param path The path to join fetch - * @return The query builder for chaining calls - */ - public X fetch(String path); - - /** - * Adds an implicit join fetch for every given path to the query. - * - * @param paths The paths to join fetch - * @return The query builder for chaining calls - */ - public X fetch(String... paths); - - /** - * Like {@link FullQueryBuilder#join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with - * {@link JoinType#INNER} and fetch set to true. - * - * @param path The path to join - * @param alias The alias for the joined element - * @return The query builder for chaining calls - */ - public X innerJoinFetch(String path, String alias); - - /** - * Like {@link FullQueryBuilder#joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with - * {@link JoinType#INNER} and fetch set to true. - * - * @param path The path to join - * @param alias The alias for the joined element - * @return The query builder for chaining calls - */ - public X innerJoinFetchDefault(String path, String alias); - - /** - * Like {@link FullQueryBuilder#join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with - * {@link JoinType#LEFT} and fetch set to true. - * - * @param path The path to join - * @param alias The alias for the joined element - * @return The query builder for chaining calls - */ - public X leftJoinFetch(String path, String alias); - - /** - * Like {@link FullQueryBuilder#joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with - * {@link JoinType#LEFT} and fetch set to true. - * - * @param path The path to join - * @param alias The alias for the joined element - * @return The query builder for chaining calls - */ - public X leftJoinFetchDefault(String path, String alias); - - /** - * Like {@link FullQueryBuilder#join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with - * {@link JoinType#RIGHT} and fetch set to true. - * - * @param path The path to join - * @param alias The alias for the joined element - * @return The query builder for chaining calls - */ - public X rightJoinFetch(String path, String alias); - - /** - * Like {@link FullQueryBuilder#joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with - * {@link JoinType#RIGHT} and fetch set to true. - * - * @param path The path to join - * @param alias The alias for the joined element - * @return The query builder for chaining calls - */ - public X rightJoinFetchDefault(String path, String alias); - - /* - * Select methods - */ - /** - * Starts a {@link SelectObjectBuilder} for the given class. The types of the parameter arguments used in the - * {@link SelectObjectBuilder} must match a constructor of the given class. - * - * @param The new query result type specified by the given class - * @param clazz The class which should be used for the select new select clause - * @return The select object builder for the given class - */ - public SelectObjectBuilder> selectNew(Class clazz); - - /** - * Starts a {@link SelectObjectBuilder} for the given constructor. The types of the parameter arguments used in the - * {@link SelectObjectBuilder} must match the given constructor. - * - * @param The new query result type specified by the given class - * @param constructor The constructor which should be used for the select new select clause - * @return The select object builder for the given class - */ - public SelectObjectBuilder> selectNew(Constructor constructor); - - /** - * Applies the given object builder to this query. The object builder provides the select clauses and is used to transform the - * result set tuples. - * - * @param The new query result type specified by the given class - * @param builder The object builder which transforms the result set into objects of type Y - * @return The query builder for chaining calls - */ - public FullQueryBuilder selectNew(ObjectBuilder builder); - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.lang.reflect.Constructor; + +/** + * A base interface for builders that support normal query functionality. + * This interface is shared between the criteria builder and paginated criteria builder. + * + * @param The query result type + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface FullQueryBuilder> extends QueryBuilder { + + /** + * Paginates the results of this query. + * + *

+ * Please note: The pagination only works on entity level and NOT on row level. This means that for queries which yield multiple + * result set rows per entity (i.e. rows with the same entity id), the multiple rows are treated as 1 page entry during the + * pagination process. Hence, the result size of such paginated queries might be greater than the specified page size. + *

+ * + *

+ * An example for such queries would be a query that joins a collection: SELECT d.id, contacts.name FROM Document d LEFT JOIN + * d.contacts contacts If one Document has associated multiple contacts, the above query will produce multiple result set rows for + * this document. + *

+ * + *

+ * Since the pagination works on entity id level, the results are implicitely grouped by id and distinct. Therefore calling + * distinct() or groupBy() on a PaginatedCriteriaBuilder is not allowed. + *

+ * + * @param firstResult The position of the first result to retrieve, numbered from 0 + * @param maxResults The maximum number of results to retrieve + * @return This query builder as paginated query builder + */ + public PaginatedCriteriaBuilder page(int firstResult, int maxResults); + + /** + * Paginates the results of this query and navigates to the page on which + * the entity with the given entity id is located. + * + * Beware that the same limitations like for {@link FullQueryBuilder#page(int, int)} apply. + * If the entity with the given entity id does not exist in the result list: + *
    + *
  • The result of {@link PaginatedCriteriaBuilder#getResultList()} will contain the first page
  • + *
  • {@link PagedList#getFirstResult()} will return -1
  • + *
+ * + * @param entityId The id of the entity which should be located on the page + * @param maxResults The maximum number of results to retrieve + * @return This query builder as paginated query builder + */ + public PaginatedCriteriaBuilder page(Object entityId, int maxResults); + + /** + * Like {@link FullQueryBuilder#page(int, int)} but additionally uses key set pagination when possible. + * + * Beware that keyset pagination should not be used as a direct replacement for offset pagination. + * Since entries that have a lower rank than some keyset might be added or removed, the calculations + * for the firstResult might be wrong. If strict pagination is required, then a keyset should + * be thrown away when the count of lower ranked items changes to make use of offset pagination again. + * + *

+ * Key set pagination is possible if and only if the following conditions are met: + *

    + *
  • This keyset reference values fit the order by expressions of this query builder AND
  • + * + *
  • {@link KeysetPage#getMaxResults()} and maxResults evaluate to the same value AND
  • + *
  • One of the following conditions is met: + *
      + *
    • The absolute value of {@link KeysetPage#getFirstResult()} - firstResult is 0
    • + *
    • The absolute value of {@link KeysetPage#getFirstResult()} - firstResult is equal to the value of + * maxResults
    • + *
    + *
  • + *
+ *

+ * + * @param keysetPage The key set from a previous result, may be null + * @param firstResult The position of the first result to retrieve, numbered from 0 + * @param maxResults The maximum number of results to retrieve + * @return This query builder as paginated query builder + * @see PagedList#getKeysetPage() + */ + public PaginatedCriteriaBuilder page(KeysetPage keysetPage, int firstResult, int maxResults); + + /* + * Join methods + */ + /** + * Adds a join to the query, possibly specializing implicit joins, and giving the joined element an alias. + * If fetch is set to true, a join fetch will be added. + * + * @param path The path to join + * @param alias The alias for the joined element + * @param type The join type + * @param fetch True if a join fetch should be added + * @return The query builder for chaining calls + */ + public X join(String path, String alias, JoinType type, boolean fetch); + + /** + * Adds a join to the query, possibly specializing implicit joins, and giving the joined element an alias. + * The resulting join will be the default join meaning that expressions which use the absolute path will refer to this join. + * If fetch is set to true, a join fetch will be added. + * + * @param path The path to join + * @param alias The alias for the joined element + * @param type The join type + * @param fetch True if a join fetch should be added + * @return The query builder for chaining calls + */ + public X joinDefault(String path, String alias, JoinType type, boolean fetch); + + /** + * Adds an implicit join fetch to the query. + * + * @param path The path to join fetch + * @return The query builder for chaining calls + */ + public X fetch(String path); + + /** + * Adds an implicit join fetch for every given path to the query. + * + * @param paths The paths to join fetch + * @return The query builder for chaining calls + */ + public X fetch(String... paths); + + /** + * Like {@link FullQueryBuilder#join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with + * {@link JoinType#INNER} and fetch set to true. + * + * @param path The path to join + * @param alias The alias for the joined element + * @return The query builder for chaining calls + */ + public X innerJoinFetch(String path, String alias); + + /** + * Like {@link FullQueryBuilder#joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with + * {@link JoinType#INNER} and fetch set to true. + * + * @param path The path to join + * @param alias The alias for the joined element + * @return The query builder for chaining calls + */ + public X innerJoinFetchDefault(String path, String alias); + + /** + * Like {@link FullQueryBuilder#join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with + * {@link JoinType#LEFT} and fetch set to true. + * + * @param path The path to join + * @param alias The alias for the joined element + * @return The query builder for chaining calls + */ + public X leftJoinFetch(String path, String alias); + + /** + * Like {@link FullQueryBuilder#joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with + * {@link JoinType#LEFT} and fetch set to true. + * + * @param path The path to join + * @param alias The alias for the joined element + * @return The query builder for chaining calls + */ + public X leftJoinFetchDefault(String path, String alias); + + /** + * Like {@link FullQueryBuilder#join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with + * {@link JoinType#RIGHT} and fetch set to true. + * + * @param path The path to join + * @param alias The alias for the joined element + * @return The query builder for chaining calls + */ + public X rightJoinFetch(String path, String alias); + + /** + * Like {@link FullQueryBuilder#joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) } but with + * {@link JoinType#RIGHT} and fetch set to true. + * + * @param path The path to join + * @param alias The alias for the joined element + * @return The query builder for chaining calls + */ + public X rightJoinFetchDefault(String path, String alias); + + /* + * Select methods + */ + /** + * Starts a {@link SelectObjectBuilder} for the given class. The types of the parameter arguments used in the + * {@link SelectObjectBuilder} must match a constructor of the given class. + * + * @param The new query result type specified by the given class + * @param clazz The class which should be used for the select new select clause + * @return The select object builder for the given class + */ + public SelectObjectBuilder> selectNew(Class clazz); + + /** + * Starts a {@link SelectObjectBuilder} for the given constructor. The types of the parameter arguments used in the + * {@link SelectObjectBuilder} must match the given constructor. + * + * @param The new query result type specified by the given class + * @param constructor The constructor which should be used for the select new select clause + * @return The select object builder for the given class + */ + public SelectObjectBuilder> selectNew(Constructor constructor); + + /** + * Applies the given object builder to this query. The object builder provides the select clauses and is used to transform the + * result set tuples. + * + * @param The new query result type specified by the given class + * @param builder The object builder which transforms the result set into objects of type Y + * @return The query builder for chaining calls + */ + public FullQueryBuilder selectNew(ObjectBuilder builder); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/FullSelectCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/FullSelectCTECriteriaBuilder.java index 9ee47869e0..a5208ca58c 100644 --- a/core/api/src/main/java/com/blazebit/persistence/FullSelectCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/FullSelectCTECriteriaBuilder.java @@ -1,34 +1,34 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for cte criteria queries. This is the entry point for building cte queries. - * - * @param The query result type which is the CTE type - * @param The result type which is returned after the CTE builder - * @author Christian Beikov - * @since 1.1.0 - */ -public interface FullSelectCTECriteriaBuilder extends SelectBaseCTECriteriaBuilder>, SetOperationBuilder, StartOngoingSetOperationCTECriteriaBuilder>> { - - /** - * Finishes the CTE builder. - * - * @return The parent query builder - */ - public X end(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for cte criteria queries. This is the entry point for building cte queries. + * + * @param The query result type which is the CTE type + * @param The result type which is returned after the CTE builder + * @author Christian Beikov + * @since 1.1.0 + */ +public interface FullSelectCTECriteriaBuilder extends SelectBaseCTECriteriaBuilder>, SetOperationBuilder, StartOngoingSetOperationCTECriteriaBuilder>> { + + /** + * Finishes the CTE builder. + * + * @return The parent query builder + */ + public X end(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/HavingAndBuilder.java b/core/api/src/main/java/com/blazebit/persistence/HavingAndBuilder.java index 38fd3c5841..dd386362f4 100644 --- a/core/api/src/main/java/com/blazebit/persistence/HavingAndBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/HavingAndBuilder.java @@ -1,41 +1,41 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * The builder interface for a having predicate container that connects predicates with the AND operator. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @since 1.0 - */ -public interface HavingAndBuilder extends BaseHavingBuilder> { - - /** - * Finishes the AND predicate and adds it to the parent predicate container represented by the type T. - * - * @return The parent predicate container builder - */ - public T endAnd(); - - /** - * Starts a having or builder which connects it's predicates with the OR operator. - * When the builder finishes, the predicate is added to this predicate container as conjunct. - * - * @return The having or builder - */ - public HavingOrBuilder> havingOr(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * The builder interface for a having predicate container that connects predicates with the AND operator. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @since 1.0 + */ +public interface HavingAndBuilder extends BaseHavingBuilder> { + + /** + * Finishes the AND predicate and adds it to the parent predicate container represented by the type T. + * + * @return The parent predicate container builder + */ + public T endAnd(); + + /** + * Starts a having or builder which connects it's predicates with the OR operator. + * When the builder finishes, the predicate is added to this predicate container as conjunct. + * + * @return The having or builder + */ + public HavingOrBuilder> havingOr(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/HavingOrBuilder.java b/core/api/src/main/java/com/blazebit/persistence/HavingOrBuilder.java index a8e6ca30a0..cec551c091 100644 --- a/core/api/src/main/java/com/blazebit/persistence/HavingOrBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/HavingOrBuilder.java @@ -1,41 +1,41 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * The builder interface for a having predicate container that connects predicates with the OR operator. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @since 1.0 - */ -public interface HavingOrBuilder extends BaseHavingBuilder> { - - /** - * Finishes the OR predicate and adds it to the parent predicate container represented by the type T. - * - * @return The parent predicate container builder - */ - public T endOr(); - - /** - * Starts a having and builder which connects it's predicates with the AND operator. - * When the builder finishes, the predicate is added to this predicate container as disjunct. - * - * @return The having and builder - */ - public HavingAndBuilder> havingAnd(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * The builder interface for a having predicate container that connects predicates with the OR operator. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @since 1.0 + */ +public interface HavingOrBuilder extends BaseHavingBuilder> { + + /** + * Finishes the OR predicate and adds it to the parent predicate container represented by the type T. + * + * @return The parent predicate container builder + */ + public T endOr(); + + /** + * Starts a having and builder which connects it's predicates with the AND operator. + * When the builder finishes, the predicate is added to this predicate container as disjunct. + * + * @return The having and builder + */ + public HavingAndBuilder> havingAnd(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/InsertCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/InsertCriteriaBuilder.java index 8b4de08531..a00c38629c 100644 --- a/core/api/src/main/java/com/blazebit/persistence/InsertCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/InsertCriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for insert queries. - * - * @param The entity type for which this update query is - * @author Christian Beikov - * @since 1.1.0 - */ -public interface InsertCriteriaBuilder extends ModificationCriteriaBuilder>, BaseInsertCriteriaBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for insert queries. + * + * @param The entity type for which this update query is + * @author Christian Beikov + * @since 1.1.0 + */ +public interface InsertCriteriaBuilder extends ModificationCriteriaBuilder>, BaseInsertCriteriaBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/JoinOnAndBuilder.java b/core/api/src/main/java/com/blazebit/persistence/JoinOnAndBuilder.java index 7f2cac78a3..17dd42e269 100644 --- a/core/api/src/main/java/com/blazebit/persistence/JoinOnAndBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/JoinOnAndBuilder.java @@ -1,41 +1,41 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * The builder interface for a on predicate container that connects predicates with the AND operator. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @since 1.0 - */ -public interface JoinOnAndBuilder extends BaseJoinOnBuilder> { - - /** - * Finishes the AND predicate and adds it to the parent predicate container represented by the type T. - * - * @return The parent predicate container builder - */ - public T endAnd(); - - /** - * Starts a on or builder which connects it's predicates with the OR operator. - * When the builder finishes, the predicate is added to this predicate container as conjunct. - * - * @return The on or builder - */ - public JoinOnOrBuilder> onOr(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * The builder interface for a on predicate container that connects predicates with the AND operator. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @since 1.0 + */ +public interface JoinOnAndBuilder extends BaseJoinOnBuilder> { + + /** + * Finishes the AND predicate and adds it to the parent predicate container represented by the type T. + * + * @return The parent predicate container builder + */ + public T endAnd(); + + /** + * Starts a on or builder which connects it's predicates with the OR operator. + * When the builder finishes, the predicate is added to this predicate container as conjunct. + * + * @return The on or builder + */ + public JoinOnOrBuilder> onOr(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/JoinOnOrBuilder.java b/core/api/src/main/java/com/blazebit/persistence/JoinOnOrBuilder.java index d4196adb81..835758d07e 100644 --- a/core/api/src/main/java/com/blazebit/persistence/JoinOnOrBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/JoinOnOrBuilder.java @@ -1,41 +1,41 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * The builder interface for a on predicate container that connects predicates with the OR operator. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @since 1.0 - */ -public interface JoinOnOrBuilder extends BaseJoinOnBuilder> { - - /** - * Finishes the OR predicate and adds it to the parent predicate container represented by the type T. - * - * @return The parent predicate container builder - */ - public T endOr(); - - /** - * Starts a on and builder which connects it's predicates with the AND operator. - * When the builder finishes, the predicate is added to this predicate container as disjunct. - * - * @return The on and builder - */ - public JoinOnAndBuilder> onAnd(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * The builder interface for a on predicate container that connects predicates with the OR operator. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @since 1.0 + */ +public interface JoinOnOrBuilder extends BaseJoinOnBuilder> { + + /** + * Finishes the OR predicate and adds it to the parent predicate container represented by the type T. + * + * @return The parent predicate container builder + */ + public T endOr(); + + /** + * Starts a on and builder which connects it's predicates with the AND operator. + * When the builder finishes, the predicate is added to this predicate container as disjunct. + * + * @return The on and builder + */ + public JoinOnAndBuilder> onAnd(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/JoinType.java b/core/api/src/main/java/com/blazebit/persistence/JoinType.java index 8bb7dfb3d1..08bdfb0597 100644 --- a/core/api/src/main/java/com/blazebit/persistence/JoinType.java +++ b/core/api/src/main/java/com/blazebit/persistence/JoinType.java @@ -1,38 +1,38 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * The different join types which are possible. - * - * @author Christian Beikov - * @since 1.0 - */ -public enum JoinType { - - /** - * Inner join - */ - INNER, - /** - * Left outer join - */ - LEFT, - /** - * Right outer join - */ - RIGHT; -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * The different join types which are possible. + * + * @author Christian Beikov + * @since 1.0 + */ +public enum JoinType { + + /** + * Inner join + */ + INNER, + /** + * Left outer join + */ + LEFT, + /** + * Right outer join + */ + RIGHT; +} diff --git a/core/api/src/main/java/com/blazebit/persistence/Keyset.java b/core/api/src/main/java/com/blazebit/persistence/Keyset.java index 176231b167..de1d361ebb 100644 --- a/core/api/src/main/java/com/blazebit/persistence/Keyset.java +++ b/core/api/src/main/java/com/blazebit/persistence/Keyset.java @@ -1,35 +1,35 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.io.Serializable; - -/** - * An interface that represents the key set of a row. - * Instances of this interface can be used for key set pagination. - * - * @author Christian Beikov - * @since 1.0 - */ -public interface Keyset extends Serializable { - - /** - * Returns the key set tuple ordered by the respective order by expressions. - * - * @return The key set tuple for this keyset - */ - public Serializable[] getTuple(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.io.Serializable; + +/** + * An interface that represents the key set of a row. + * Instances of this interface can be used for key set pagination. + * + * @author Christian Beikov + * @since 1.0 + */ +public interface Keyset extends Serializable { + + /** + * Returns the key set tuple ordered by the respective order by expressions. + * + * @return The key set tuple for this keyset + */ + public Serializable[] getTuple(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/KeysetBuilder.java b/core/api/src/main/java/com/blazebit/persistence/KeysetBuilder.java index e7bbb2d29f..58853add8b 100644 --- a/core/api/src/main/java/com/blazebit/persistence/KeysetBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/KeysetBuilder.java @@ -1,44 +1,44 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for keysets to make use of keyset pagination. - * This is used for building a keyset declaratively. - * - * @param The builder result type - * @author Christian Beikov - * @since 1.0 - */ -public interface KeysetBuilder { - - /** - * Uses the given value as reference value for keyset pagination for the given expression. - * Normally the expression is one of the order by expressions used in the query. - * - * @param expression The order by expression for which a value should be provided - * @param value The reference value from which the keyset pagination can start from - * @return This keyset builder - */ - public KeysetBuilder with(String expression, Object value); - - /** - * Finishes the keyset builder. - * - * @return The query builder - */ - public T end(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for keysets to make use of keyset pagination. + * This is used for building a keyset declaratively. + * + * @param The builder result type + * @author Christian Beikov + * @since 1.0 + */ +public interface KeysetBuilder { + + /** + * Uses the given value as reference value for keyset pagination for the given expression. + * Normally the expression is one of the order by expressions used in the query. + * + * @param expression The order by expression for which a value should be provided + * @param value The reference value from which the keyset pagination can start from + * @return This keyset builder + */ + public KeysetBuilder with(String expression, Object value); + + /** + * Finishes the keyset builder. + * + * @return The query builder + */ + public T end(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/KeysetPage.java b/core/api/src/main/java/com/blazebit/persistence/KeysetPage.java index 893342d689..94a55f9ba2 100644 --- a/core/api/src/main/java/com/blazebit/persistence/KeysetPage.java +++ b/core/api/src/main/java/com/blazebit/persistence/KeysetPage.java @@ -1,58 +1,58 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.io.Serializable; - -/** - * An interface that represents the key set of a {@link PagedList}. - * Instances of this interface can be used for key set pagination. - * - * @author Christian Beikov - * @since 1.0 - */ -public interface KeysetPage extends Serializable { - - /** - * Returns the position of the first result, numbered from 0. - * This is the position of the first element of this key set. - * - * @return The position of the first result - */ - public int getFirstResult(); - - /** - * Returns the maximum number of results. - * This is the maximum number of results of this key set. - * - * @return The maximum number of results - */ - public int getMaxResults(); - - /** - * Returns the key set for the lowest entry of the corresponding {@link PagedList}. - * - * @return The key set for the lowest entry - */ - public Keyset getLowest(); - - /** - * Returns the key set for the highest entry of the corresponding {@link PagedList}. - * - * @return The key set for the highest entry - */ - public Keyset getHighest(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.io.Serializable; + +/** + * An interface that represents the key set of a {@link PagedList}. + * Instances of this interface can be used for key set pagination. + * + * @author Christian Beikov + * @since 1.0 + */ +public interface KeysetPage extends Serializable { + + /** + * Returns the position of the first result, numbered from 0. + * This is the position of the first element of this key set. + * + * @return The position of the first result + */ + public int getFirstResult(); + + /** + * Returns the maximum number of results. + * This is the maximum number of results of this key set. + * + * @return The maximum number of results + */ + public int getMaxResults(); + + /** + * Returns the key set for the lowest entry of the corresponding {@link PagedList}. + * + * @return The key set for the lowest entry + */ + public Keyset getLowest(); + + /** + * Returns the key set for the highest entry of the corresponding {@link PagedList}. + * + * @return The key set for the highest entry + */ + public Keyset getHighest(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/KeysetQueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/KeysetQueryBuilder.java index 1cf2fbc84f..cd9a8dca37 100644 --- a/core/api/src/main/java/com/blazebit/persistence/KeysetQueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/KeysetQueryBuilder.java @@ -1,82 +1,82 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.io.Serializable; - -/** - * A base interface for builders that support keyset filtering. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.0 - */ -public interface KeysetQueryBuilder> { - - /** - * Uses the keyset which the keyset builder constructed to filter out rows that come after the keyset. - * Based on the order by expressions, the keyset builder should receive reference values for every used expression. - * The constructed keyset will be filtered out so this is like a "lower than" filter. - * - * @return The keyset builder for specifing the keyset - */ - public KeysetBuilder beforeKeyset(); - - /** - * Like {@link FullQueryBuilder#beforeKeyset()} but maps the reference values by position instead of by expression. - * The order of the reference values has to match the order of the order by expressions. - * - * @param values The reference values - * @return The query builder for chaining calls - */ - public X beforeKeyset(Serializable... values); - - /** - * Like {@link FullQueryBuilder#beforeKeyset(java.io.Serializable...)} but uses the given keyset as reference values. - * The order of the tuple values has to match the order of the order by expressions. - * - * @param keyset The reference keyset - * @return The query builder for chaining calls - */ - public X beforeKeyset(Keyset keyset); - - /** - * Uses the keyset which the keyset builder constructed to filter out rows that come before the keyset. - * Based on the order by expressions, the keyset builder should receive reference values for every used expression. - * The constructed keyset will be filtered out so this is like a "greater than" filter. - * - * @return The keyset builder for specifing the keyset - */ - public KeysetBuilder afterKeyset(); - - /** - * Like {@link FullQueryBuilder#afterKeyset()} but maps the reference values by position instead of by expression. - * The order of the reference values has to match the order of the order by expressions. - * - * @param values The reference values - * @return The query builder for chaining calls - */ - public X afterKeyset(Serializable... values); - - /** - * Like {@link FullQueryBuilder#afterKeyset(java.io.Serializable...)} but uses the given keyset as reference values. - * The order of the tuple values has to match the order of the order by expressions. - * - * @param keyset The reference keyset - * @return The query builder for chaining calls - */ - public X afterKeyset(Keyset keyset); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.io.Serializable; + +/** + * A base interface for builders that support keyset filtering. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.0 + */ +public interface KeysetQueryBuilder> { + + /** + * Uses the keyset which the keyset builder constructed to filter out rows that come after the keyset. + * Based on the order by expressions, the keyset builder should receive reference values for every used expression. + * The constructed keyset will be filtered out so this is like a "lower than" filter. + * + * @return The keyset builder for specifing the keyset + */ + public KeysetBuilder beforeKeyset(); + + /** + * Like {@link FullQueryBuilder#beforeKeyset()} but maps the reference values by position instead of by expression. + * The order of the reference values has to match the order of the order by expressions. + * + * @param values The reference values + * @return The query builder for chaining calls + */ + public X beforeKeyset(Serializable... values); + + /** + * Like {@link FullQueryBuilder#beforeKeyset(java.io.Serializable...)} but uses the given keyset as reference values. + * The order of the tuple values has to match the order of the order by expressions. + * + * @param keyset The reference keyset + * @return The query builder for chaining calls + */ + public X beforeKeyset(Keyset keyset); + + /** + * Uses the keyset which the keyset builder constructed to filter out rows that come before the keyset. + * Based on the order by expressions, the keyset builder should receive reference values for every used expression. + * The constructed keyset will be filtered out so this is like a "greater than" filter. + * + * @return The keyset builder for specifing the keyset + */ + public KeysetBuilder afterKeyset(); + + /** + * Like {@link FullQueryBuilder#afterKeyset()} but maps the reference values by position instead of by expression. + * The order of the reference values has to match the order of the order by expressions. + * + * @param values The reference values + * @return The query builder for chaining calls + */ + public X afterKeyset(Serializable... values); + + /** + * Like {@link FullQueryBuilder#afterKeyset(java.io.Serializable...)} but uses the given keyset as reference values. + * The order of the tuple values has to match the order of the order by expressions. + * + * @param keyset The reference keyset + * @return The query builder for chaining calls + */ + public X afterKeyset(Keyset keyset); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationCTECriteriaBuilder.java index 3938b08ab3..927aae8bc4 100644 --- a/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationCTECriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @param The builder result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface LeafOngoingSetOperationCTECriteriaBuilder extends BaseOngoingSetOperationBuilder, FinalSetOperationCTECriteriaBuilder, StartOngoingSetOperationCTECriteriaBuilder>>, SelectBaseCTECriteriaBuilder> { -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @param The builder result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface LeafOngoingSetOperationCTECriteriaBuilder extends BaseOngoingSetOperationBuilder, FinalSetOperationCTECriteriaBuilder, StartOngoingSetOperationCTECriteriaBuilder>>, SelectBaseCTECriteriaBuilder> { +} diff --git a/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationCriteriaBuilder.java index b5baad764e..52448f08dc 100644 --- a/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationCriteriaBuilder.java @@ -1,26 +1,26 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface LeafOngoingSetOperationCriteriaBuilder extends BaseOngoingSetOperationBuilder, FinalSetOperationCriteriaBuilder, StartOngoingSetOperationCriteriaBuilder>>, BaseCriteriaBuilder> { -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface LeafOngoingSetOperationCriteriaBuilder extends BaseOngoingSetOperationBuilder, FinalSetOperationCriteriaBuilder, StartOngoingSetOperationCriteriaBuilder>>, BaseCriteriaBuilder> { +} diff --git a/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationSubqueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationSubqueryBuilder.java index eba6d6cc49..319105fc48 100644 --- a/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationSubqueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/LeafOngoingSetOperationSubqueryBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @param The builder result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface LeafOngoingSetOperationSubqueryBuilder extends BaseOngoingSetOperationBuilder, FinalSetOperationSubqueryBuilder, StartOngoingSetOperationSubqueryBuilder>>, BaseSubqueryBuilder> { -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @param The builder result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface LeafOngoingSetOperationSubqueryBuilder extends BaseOngoingSetOperationBuilder, FinalSetOperationSubqueryBuilder, StartOngoingSetOperationSubqueryBuilder>>, BaseSubqueryBuilder> { +} diff --git a/core/api/src/main/java/com/blazebit/persistence/LikeBuilder.java b/core/api/src/main/java/com/blazebit/persistence/LikeBuilder.java index 2500e36101..77e5f51b2f 100644 --- a/core/api/src/main/java/com/blazebit/persistence/LikeBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/LikeBuilder.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence; - -/** - * A builder for the like predicate. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public interface LikeBuilder extends BinaryPredicateBuilder> { - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence; + +/** + * A builder for the like predicate. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public interface LikeBuilder extends BinaryPredicateBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/LimitBuilder.java b/core/api/src/main/java/com/blazebit/persistence/LimitBuilder.java index b62668f6b0..ace5910ede 100644 --- a/core/api/src/main/java/com/blazebit/persistence/LimitBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/LimitBuilder.java @@ -1,40 +1,40 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support limit and offset. - * This is related to the fact, that a query builder supports the limit and offset clause. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface LimitBuilder> { - - // TODO: documentation - public X setFirstResult(int firstResult); - - // TODO: documentation - public X setMaxResults(int maxResults); - - // TODO: documentation - public int getFirstResult(); - - // TODO: documentation - public int getMaxResults(); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support limit and offset. + * This is related to the fact, that a query builder supports the limit and offset clause. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface LimitBuilder> { + + // TODO: documentation + public X setFirstResult(int firstResult); + + // TODO: documentation + public X setMaxResults(int maxResults); + + // TODO: documentation + public int getFirstResult(); + + // TODO: documentation + public int getMaxResults(); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ObjectBuilder.java b/core/api/src/main/java/com/blazebit/persistence/ObjectBuilder.java index ba200ea640..4db57048b4 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ObjectBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/ObjectBuilder.java @@ -1,52 +1,52 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.util.List; - -/** - * An object build provides the select clause expressions that should be used by a {@link FullQueryBuilder} and provides methods for - * transforming tuples into the target type T. - * - * @param The type that this builder produces - * @author Christian Beikov - * @since 1.0 - */ -public interface ObjectBuilder { - - /** - * Applies the select items necessary for this object builder to work. - * - * @param selectBuilder The selectBuilder on which to apply the selects - */ - public > void applySelects(X selectBuilder); - - /** - * Builds an object of the target type T from the given tuple. - * - * @param tuple The result tuple - * @return The target object - */ - public T build(Object[] tuple); - - /** - * Transforms the given list and returns the result. - * - * @param list The list to be transformed - * @return The resulting list - */ - public List buildList(List list); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.util.List; + +/** + * An object build provides the select clause expressions that should be used by a {@link FullQueryBuilder} and provides methods for + * transforming tuples into the target type T. + * + * @param The type that this builder produces + * @author Christian Beikov + * @since 1.0 + */ +public interface ObjectBuilder { + + /** + * Applies the select items necessary for this object builder to work. + * + * @param selectBuilder The selectBuilder on which to apply the selects + */ + public > void applySelects(X selectBuilder); + + /** + * Builds an object of the target type T from the given tuple. + * + * @param tuple The result tuple + * @return The target object + */ + public T build(Object[] tuple); + + /** + * Transforms the given list and returns the result. + * + * @param list The list to be transformed + * @return The resulting list + */ + public List buildList(List list); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationCTECriteriaBuilder.java index 59ea6234d6..bcb0385363 100644 --- a/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationCTECriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The builder result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface OngoingFinalSetOperationCTECriteriaBuilder extends BaseOngoingFinalSetOperationBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The builder result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface OngoingFinalSetOperationCTECriteriaBuilder extends BaseOngoingFinalSetOperationBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationCriteriaBuilder.java index 81e04d3563..a1c75c1f89 100644 --- a/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationCriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The builder result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface OngoingFinalSetOperationCriteriaBuilder extends BaseOngoingFinalSetOperationBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The builder result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface OngoingFinalSetOperationCriteriaBuilder extends BaseOngoingFinalSetOperationBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationSubqueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationSubqueryBuilder.java index fe58880857..bd7f66ab1c 100644 --- a/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationSubqueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/OngoingFinalSetOperationSubqueryBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The result type which is returned after the subquery builder - * @author Christian Beikov - * @since 1.1.0 - */ -public interface OngoingFinalSetOperationSubqueryBuilder extends BaseOngoingFinalSetOperationBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The result type which is returned after the subquery builder + * @author Christian Beikov + * @since 1.1.0 + */ +public interface OngoingFinalSetOperationSubqueryBuilder extends BaseOngoingFinalSetOperationBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationBuilder.java b/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationBuilder.java index cd5d0019f6..5f9bb08edb 100644 --- a/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationBuilder.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @param The set sub-operation result type - * @param The set nesting start type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface OngoingSetOperationBuilder> extends BaseOngoingSetOperationBuilder { - - public BaseOngoingFinalSetOperationBuilder endSetWith(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @param The set sub-operation result type + * @param The set nesting start type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface OngoingSetOperationBuilder> extends BaseOngoingSetOperationBuilder { + + public BaseOngoingFinalSetOperationBuilder endSetWith(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationCTECriteriaBuilder.java index b8fb6ec7c9..b71cf6e2fb 100644 --- a/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationCTECriteriaBuilder.java @@ -1,29 +1,29 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The builder result type - * @param The set sub-operation result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface OngoingSetOperationCTECriteriaBuilder extends OngoingSetOperationBuilder, Y, StartOngoingSetOperationCTECriteriaBuilder>>, SelectBaseCTECriteriaBuilder> { - - public OngoingFinalSetOperationCTECriteriaBuilder endSetWith(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The builder result type + * @param The set sub-operation result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface OngoingSetOperationCTECriteriaBuilder extends OngoingSetOperationBuilder, Y, StartOngoingSetOperationCTECriteriaBuilder>>, SelectBaseCTECriteriaBuilder> { + + public OngoingFinalSetOperationCTECriteriaBuilder endSetWith(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationCriteriaBuilder.java index 9ec8f35c5e..668e15f7e0 100644 --- a/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationCriteriaBuilder.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The builder result type - * @param The set sub-operation result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface OngoingSetOperationCriteriaBuilder extends OngoingSetOperationBuilder, Y, StartOngoingSetOperationCriteriaBuilder>>, BaseCriteriaBuilder> { - - @Override - public OngoingFinalSetOperationCriteriaBuilder endSetWith(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The builder result type + * @param The set sub-operation result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface OngoingSetOperationCriteriaBuilder extends OngoingSetOperationBuilder, Y, StartOngoingSetOperationCriteriaBuilder>>, BaseCriteriaBuilder> { + + @Override + public OngoingFinalSetOperationCriteriaBuilder endSetWith(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationSubqueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationSubqueryBuilder.java index 0cceb60501..14c2e5ce50 100644 --- a/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationSubqueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/OngoingSetOperationSubqueryBuilder.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The builder result type - * @param The set sub-operation result type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface OngoingSetOperationSubqueryBuilder extends OngoingSetOperationBuilder, Y, StartOngoingSetOperationSubqueryBuilder>>, BaseSubqueryBuilder> { - - @Override - public OngoingFinalSetOperationSubqueryBuilder endSetWith(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The builder result type + * @param The set sub-operation result type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface OngoingSetOperationSubqueryBuilder extends OngoingSetOperationBuilder, Y, StartOngoingSetOperationSubqueryBuilder>>, BaseSubqueryBuilder> { + + @Override + public OngoingFinalSetOperationSubqueryBuilder endSetWith(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/PaginatedCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/PaginatedCriteriaBuilder.java index 6da859f1c1..37d45861f5 100644 --- a/core/api/src/main/java/com/blazebit/persistence/PaginatedCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/PaginatedCriteriaBuilder.java @@ -1,70 +1,70 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for paginated criteria queries. - * - * @param The query result type - * @author Christian Beikov - * @since 1.0 - */ -public interface PaginatedCriteriaBuilder extends FullQueryBuilder> { - - /** - * Returns the query string that selects the count of elements. - * - * @return The query string - */ - public String getPageCountQueryString(); - - /** - * Returns the query string that selects the id of the elements. - * - * @return The query string - */ - public String getPageIdQueryString(); - - /** - * Enable or disables keyset extraction which influences whether {@link PagedList#getKeysetPage()} is available. - * - * @param keysetExtraction true to enable, false to disable keyset extraction - * @return The query builder for chaining calls - */ - public PaginatedCriteriaBuilder withKeysetExtraction(boolean keysetExtraction); - - /** - * Returns whether keyset extraction is enabled or not. - * - * @return true when enabled, false otherwise - */ - public boolean isKeysetExtraction(); - - /** - * Execute the query and return the result as a type PagedList. - * - * @return The paged list of the results - */ - @Override - public PagedList getResultList(); - - @Override - public SelectObjectBuilder> selectNew(Class clazz); - - @Override - public PaginatedCriteriaBuilder selectNew(ObjectBuilder builder); - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for paginated criteria queries. + * + * @param The query result type + * @author Christian Beikov + * @since 1.0 + */ +public interface PaginatedCriteriaBuilder extends FullQueryBuilder> { + + /** + * Returns the query string that selects the count of elements. + * + * @return The query string + */ + public String getPageCountQueryString(); + + /** + * Returns the query string that selects the id of the elements. + * + * @return The query string + */ + public String getPageIdQueryString(); + + /** + * Enable or disables keyset extraction which influences whether {@link PagedList#getKeysetPage()} is available. + * + * @param keysetExtraction true to enable, false to disable keyset extraction + * @return The query builder for chaining calls + */ + public PaginatedCriteriaBuilder withKeysetExtraction(boolean keysetExtraction); + + /** + * Returns whether keyset extraction is enabled or not. + * + * @return true when enabled, false otherwise + */ + public boolean isKeysetExtraction(); + + /** + * Execute the query and return the result as a type PagedList. + * + * @return The paged list of the results + */ + @Override + public PagedList getResultList(); + + @Override + public SelectObjectBuilder> selectNew(Class clazz); + + @Override + public PaginatedCriteriaBuilder selectNew(ObjectBuilder builder); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/QuantifiableBinaryPredicateBuilder.java b/core/api/src/main/java/com/blazebit/persistence/QuantifiableBinaryPredicateBuilder.java index b67572c3f0..40af01aa31 100644 --- a/core/api/src/main/java/com/blazebit/persistence/QuantifiableBinaryPredicateBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/QuantifiableBinaryPredicateBuilder.java @@ -1,44 +1,44 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * The interface for quantifiable binary predicate builders. - * The left hand side and the operator are already known to the builder and the methods of this builder either terminate the building - * process or start a {@link SubqueryInitiator}. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @since 1.0 - */ -public interface QuantifiableBinaryPredicateBuilder extends BinaryPredicateBuilder, SubqueryInitiator { - - /** - * Starts a {@link SubqueryInitiator} for the right hand side of a predicate that uses the ALL quantor. - * When the builder finishes, the predicate is added to the parent predicate container represented by the type T. - * - * @return The subquery initiator for building a subquery - */ - public SubqueryInitiator all(); - - /** - * Starts a {@link SubqueryInitiator} for the right hand side of a predicate that uses the ANY quantor. - * When the builder finishes, the predicate is added to the parent predicate container represented by the type T. - * - * @return The subquery initiator for building a subquery - */ - public SubqueryInitiator any(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * The interface for quantifiable binary predicate builders. + * The left hand side and the operator are already known to the builder and the methods of this builder either terminate the building + * process or start a {@link SubqueryInitiator}. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @since 1.0 + */ +public interface QuantifiableBinaryPredicateBuilder extends BinaryPredicateBuilder, SubqueryInitiator { + + /** + * Starts a {@link SubqueryInitiator} for the right hand side of a predicate that uses the ALL quantor. + * When the builder finishes, the predicate is added to the parent predicate container represented by the type T. + * + * @return The subquery initiator for building a subquery + */ + public SubqueryInitiator all(); + + /** + * Starts a {@link SubqueryInitiator} for the right hand side of a predicate that uses the ANY quantor. + * When the builder finishes, the predicate is added to the parent predicate container represented by the type T. + * + * @return The subquery initiator for building a subquery + */ + public SubqueryInitiator any(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/QueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/QueryBuilder.java index 9d31f6f8fb..bb877a9e14 100644 --- a/core/api/src/main/java/com/blazebit/persistence/QueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/QueryBuilder.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - - -/** - * A base interface for builders that support normal query functionality. - * This interface is shared between the criteria builder and paginated criteria builder. - * - * @param The query result type - * @param The concrete builder type - * @author Christian Beikov - * @since 1.0 - */ -public interface QueryBuilder> extends BaseQueryBuilder, Queryable { -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + + +/** + * A base interface for builders that support normal query functionality. + * This interface is shared between the criteria builder and paginated criteria builder. + * + * @param The query result type + * @param The concrete builder type + * @author Christian Beikov + * @since 1.0 + */ +public interface QueryBuilder> extends BaseQueryBuilder, Queryable { +} diff --git a/core/api/src/main/java/com/blazebit/persistence/Queryable.java b/core/api/src/main/java/com/blazebit/persistence/Queryable.java index b39734bc45..f31e0a7210 100644 --- a/core/api/src/main/java/com/blazebit/persistence/Queryable.java +++ b/core/api/src/main/java/com/blazebit/persistence/Queryable.java @@ -1,61 +1,61 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.util.List; - -import javax.persistence.TypedQuery; - -/** - * A base interface for builders that querying. - * - * @param The query result type - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface Queryable> { - - /** - * Returns the query string for the built query. - * - * @return The query string - */ - public String getQueryString(); - - /** - * Returns the JPA typed query for the built query. - * The returned query is already parameterized with all known parameters. - * - * @return The typed query for the built query - */ - public TypedQuery getQuery(); - - /** - * Execute the query and return the result as a type List. - * - * @return The list of the results - */ - public List getResultList(); - - /** - * Execute the query expecting a single result. - * - * @return The single result - */ - public T getSingleResult(); - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.util.List; + +import javax.persistence.TypedQuery; + +/** + * A base interface for builders that querying. + * + * @param The query result type + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface Queryable> { + + /** + * Returns the query string for the built query. + * + * @return The query string + */ + public String getQueryString(); + + /** + * Returns the JPA typed query for the built query. + * The returned query is already parameterized with all known parameters. + * + * @return The typed query for the built query + */ + public TypedQuery getQuery(); + + /** + * Execute the query and return the result as a type List. + * + * @return The list of the results + */ + public List getResultList(); + + /** + * Execute the query expecting a single result. + * + * @return The single result + */ + public T getSingleResult(); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ReturningBuilder.java b/core/api/src/main/java/com/blazebit/persistence/ReturningBuilder.java index 654968143e..34a60a7f51 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ReturningBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/ReturningBuilder.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for the returning clause. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface ReturningBuilder> { - - // TODO: documentation - public X returning(String cteAttribute, String modificationQueryAttribute); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for the returning clause. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface ReturningBuilder> { + + // TODO: documentation + public X returning(String cteAttribute, String modificationQueryAttribute); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ReturningDeleteCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/ReturningDeleteCriteriaBuilder.java index 3558002ae4..3bd77758e2 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ReturningDeleteCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/ReturningDeleteCriteriaBuilder.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for delete queries. - * - * @param The entity type for which this delete query is - * @param The parent query build type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface ReturningDeleteCriteriaBuilder extends ReturningModificationCriteriaBuilder, X>, BaseDeleteCriteriaBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for delete queries. + * + * @param The entity type for which this delete query is + * @param The parent query build type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface ReturningDeleteCriteriaBuilder extends ReturningModificationCriteriaBuilder, X>, BaseDeleteCriteriaBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ReturningInsertCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/ReturningInsertCriteriaBuilder.java index 1a3d08e60a..fbd5d0fc42 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ReturningInsertCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/ReturningInsertCriteriaBuilder.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for insert queries. - * - * @param The entity type for which this update query is - * @param The parent query build type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface ReturningInsertCriteriaBuilder extends ReturningModificationCriteriaBuilder, X>, BaseInsertCriteriaBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for insert queries. + * + * @param The entity type for which this update query is + * @param The parent query build type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface ReturningInsertCriteriaBuilder extends ReturningModificationCriteriaBuilder, X>, BaseInsertCriteriaBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ReturningModificationCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/ReturningModificationCriteriaBuilder.java index f519b0eb88..1a1275a634 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ReturningModificationCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/ReturningModificationCriteriaBuilder.java @@ -1,31 +1,31 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for modification queries. - * - * @param The concrete builder type - * @param The parent query build type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface ReturningModificationCriteriaBuilder, Y> extends CommonQueryBuilder, BaseModificationCriteriaBuilder, ReturningBuilder { - - // TODO: documentation - public Y end(); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for modification queries. + * + * @param The concrete builder type + * @param The parent query build type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface ReturningModificationCriteriaBuilder, Y> extends CommonQueryBuilder, BaseModificationCriteriaBuilder, ReturningBuilder { + + // TODO: documentation + public Y end(); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ReturningModificationCriteriaBuilderFactory.java b/core/api/src/main/java/com/blazebit/persistence/ReturningModificationCriteriaBuilderFactory.java index 8f954b3626..50d080e3d5 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ReturningModificationCriteriaBuilderFactory.java +++ b/core/api/src/main/java/com/blazebit/persistence/ReturningModificationCriteriaBuilderFactory.java @@ -1,80 +1,80 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for modification queries that return results. - * - * @param The entity type for which this delete query is - * @author Christian Beikov - * @since 1.1.0 - */ -public interface ReturningModificationCriteriaBuilderFactory { - - /** - * Like {@link ReturningModificationCriteriaBuilderFactory#delete(java.lang.Class, java.lang.String)} but with the alias - * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the delete class returns. - * - * @param deleteClass The entity class for the delete criteria - * @param The type of the entity for the delete criteria - * @return A new delete criteria builder - * @since 1.1.0 - */ - public ReturningDeleteCriteriaBuilder delete(Class deleteClass); - - /** - * Creates a new delete criteria builder for the given entity class. - * - * @param deleteClass The entity class for the delete criteria - * @param alias The alias that should be used for the entity - * @param The type of the entity for the delete criteria - * @return A new delete criteria builder - * @since 1.1.0 - */ - public ReturningDeleteCriteriaBuilder delete(Class deleteClass, String alias); - - /** - * Like {@link ReturningModificationCriteriaBuilderFactory#update(java.lang.Class, java.lang.String)} but with the alias - * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the update class returns. - * - * @param updateClass The entity class for the update criteria - * @param The type of the entity for the update criteria - * @return A new update criteria builder - * @since 1.1.0 - */ - public ReturningUpdateCriteriaBuilder update(Class updateClass); - - /** - * Creates a new update criteria builder for the given entity class. - * - * @param updateClass The entity class for the update criteria - * @param alias The alias that should be used for the entity - * @param The type of the entity for the update criteria - * @return A new update criteria builder - * @since 1.1.0 - */ - public ReturningUpdateCriteriaBuilder update(Class updateClass, String alias); - - /** - * Creates a new insert criteria builder for the given entity class. - * - * @param insertClass The entity class for the insert criteria - * @param The type of the entity for the insert criteria - * @return A new insert criteria builder - * @since 1.1.0 - */ - public ReturningInsertCriteriaBuilder insert(Class insertClass); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for modification queries that return results. + * + * @param The entity type for which this delete query is + * @author Christian Beikov + * @since 1.1.0 + */ +public interface ReturningModificationCriteriaBuilderFactory { + + /** + * Like {@link ReturningModificationCriteriaBuilderFactory#delete(java.lang.Class, java.lang.String)} but with the alias + * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the delete class returns. + * + * @param deleteClass The entity class for the delete criteria + * @param The type of the entity for the delete criteria + * @return A new delete criteria builder + * @since 1.1.0 + */ + public ReturningDeleteCriteriaBuilder delete(Class deleteClass); + + /** + * Creates a new delete criteria builder for the given entity class. + * + * @param deleteClass The entity class for the delete criteria + * @param alias The alias that should be used for the entity + * @param The type of the entity for the delete criteria + * @return A new delete criteria builder + * @since 1.1.0 + */ + public ReturningDeleteCriteriaBuilder delete(Class deleteClass, String alias); + + /** + * Like {@link ReturningModificationCriteriaBuilderFactory#update(java.lang.Class, java.lang.String)} but with the alias + * equivalent to the camel cased result of what {@link Class#getSimpleName()} of the update class returns. + * + * @param updateClass The entity class for the update criteria + * @param The type of the entity for the update criteria + * @return A new update criteria builder + * @since 1.1.0 + */ + public ReturningUpdateCriteriaBuilder update(Class updateClass); + + /** + * Creates a new update criteria builder for the given entity class. + * + * @param updateClass The entity class for the update criteria + * @param alias The alias that should be used for the entity + * @param The type of the entity for the update criteria + * @return A new update criteria builder + * @since 1.1.0 + */ + public ReturningUpdateCriteriaBuilder update(Class updateClass, String alias); + + /** + * Creates a new insert criteria builder for the given entity class. + * + * @param insertClass The entity class for the insert criteria + * @param The type of the entity for the insert criteria + * @return A new insert criteria builder + * @since 1.1.0 + */ + public ReturningInsertCriteriaBuilder insert(Class insertClass); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ReturningObjectBuilder.java b/core/api/src/main/java/com/blazebit/persistence/ReturningObjectBuilder.java index bf2ea1459f..49fc2335c0 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ReturningObjectBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/ReturningObjectBuilder.java @@ -1,52 +1,52 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.util.List; - -/** - * An object build provides the returning bindings that should be used by a {@link ReturningModificationCriteriaBuilder} and provides methods for - * transforming tuples into the target type T. - * - * @param The type that this builder produces - * @author Christian Beikov - * @since 1.1.0 - */ -public interface ReturningObjectBuilder { - - /** - * Applies the returning bindings necessary for this object builder to work. - * - * @param returningBuilder The returningBuilder on which to apply the returning bindings - */ - public > void applyReturning(X returningBuilder); - - /** - * Builds an object of the target type T from the given tuple. - * - * @param tuple The result tuple - * @return The target object - */ - public T build(Object[] tuple); - - /** - * Transforms the given list and returns the result. - * - * @param list The list to be transformed - * @return The resulting list - */ - public List buildList(List list); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.util.List; + +/** + * An object build provides the returning bindings that should be used by a {@link ReturningModificationCriteriaBuilder} and provides methods for + * transforming tuples into the target type T. + * + * @param The type that this builder produces + * @author Christian Beikov + * @since 1.1.0 + */ +public interface ReturningObjectBuilder { + + /** + * Applies the returning bindings necessary for this object builder to work. + * + * @param returningBuilder The returningBuilder on which to apply the returning bindings + */ + public > void applyReturning(X returningBuilder); + + /** + * Builds an object of the target type T from the given tuple. + * + * @param tuple The result tuple + * @return The target object + */ + public T build(Object[] tuple); + + /** + * Transforms the given list and returns the result. + * + * @param list The list to be transformed + * @return The resulting list + */ + public List buildList(List list); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ReturningResult.java b/core/api/src/main/java/com/blazebit/persistence/ReturningResult.java index 2065e0abf8..bd3d57e210 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ReturningResult.java +++ b/core/api/src/main/java/com/blazebit/persistence/ReturningResult.java @@ -1,52 +1,52 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -import java.util.List; - -/** - * A builder for modification queries. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface ReturningResult { - - /** - * Returns the last element of the returning clause result. - * - * @return the last element of the returning clause result - */ - public T getLastResult(); - - /** - * Returns the result of the returning clause. - * - * Note that returning all elements might not be supported by all databases. - * - * @return The result of the returning clause - */ - public List getResultList(); - - /** - * Execute this modification statement and return the number of affected entities. - * - * @return The number of affected entities - */ - public int getUpdateCount(); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +import java.util.List; + +/** + * A builder for modification queries. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface ReturningResult { + + /** + * Returns the last element of the returning clause result. + * + * @return the last element of the returning clause result + */ + public T getLastResult(); + + /** + * Returns the result of the returning clause. + * + * Note that returning all elements might not be supported by all databases. + * + * @return The result of the returning clause + */ + public List getResultList(); + + /** + * Execute this modification statement and return the number of affected entities. + * + * @return The number of affected entities + */ + public int getUpdateCount(); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/ReturningUpdateCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/ReturningUpdateCriteriaBuilder.java index ded870395f..17e2ce6a32 100644 --- a/core/api/src/main/java/com/blazebit/persistence/ReturningUpdateCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/ReturningUpdateCriteriaBuilder.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for update queries. - * - * @param The entity type for which this update query is - * @param The parent query build type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface ReturningUpdateCriteriaBuilder extends ReturningModificationCriteriaBuilder, X>, BaseUpdateCriteriaBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for update queries. + * + * @param The entity type for which this update query is + * @param The parent query build type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface ReturningUpdateCriteriaBuilder extends ReturningModificationCriteriaBuilder, X>, BaseUpdateCriteriaBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/SelectBaseCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/SelectBaseCTECriteriaBuilder.java index 7f899d8fae..c723936504 100644 --- a/core/api/src/main/java/com/blazebit/persistence/SelectBaseCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/SelectBaseCTECriteriaBuilder.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for cte criteria queries that select. This is the entry point for building cte queries. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface SelectBaseCTECriteriaBuilder> extends BaseCTECriteriaBuilder { - - public SelectBuilder bind(String cteAttribute); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for cte criteria queries that select. This is the entry point for building cte queries. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface SelectBaseCTECriteriaBuilder> extends BaseCTECriteriaBuilder { + + public SelectBuilder bind(String cteAttribute); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/SelectCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/SelectCTECriteriaBuilder.java index 3d9a8cf2de..7d6cdca55a 100644 --- a/core/api/src/main/java/com/blazebit/persistence/SelectCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/SelectCTECriteriaBuilder.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for cte criteria queries. This is the entry point for building cte queries. - * - * @param The result type which is returned after the CTE builder - * @author Christian Beikov - * @since 1.1.0 - */ -public interface SelectCTECriteriaBuilder extends SelectBaseCTECriteriaBuilder> { - - /** - * Finishes the CTE builder. - * - * @return The parent query builder - */ - public X end(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for cte criteria queries. This is the entry point for building cte queries. + * + * @param The result type which is returned after the CTE builder + * @author Christian Beikov + * @since 1.1.0 + */ +public interface SelectCTECriteriaBuilder extends SelectBaseCTECriteriaBuilder> { + + /** + * Finishes the CTE builder. + * + * @return The parent query builder + */ + public X end(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/SelectRecursiveCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/SelectRecursiveCTECriteriaBuilder.java index 42d3683b03..edee967e20 100644 --- a/core/api/src/main/java/com/blazebit/persistence/SelectRecursiveCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/SelectRecursiveCTECriteriaBuilder.java @@ -1,42 +1,42 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for CTE criteria queries. This is the entry point for building CTE queries. - * - * @param The result type which is returned afte the CTE builder - * @author Christian Beikov - * @since 1.1.0 - */ -public interface SelectRecursiveCTECriteriaBuilder extends SelectBaseCTECriteriaBuilder> { - - /** - * Finishes the CTE builder for the non-recursive part and starts the builder for the recursive part. - * The union operator is used for connecting the non-recursive and recursive part, thus removing duplicates. - * - * @return The parent query builder - */ - public SelectCTECriteriaBuilder union(); - - /** - * Finishes the CTE builder for the non-recursive part and starts the builder for the recursive part. - * The union all operator is used for connecting the non-recursive and recursive part, thus not removing duplicates. - * - * @return The parent query builder - */ - public SelectCTECriteriaBuilder unionAll(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for CTE criteria queries. This is the entry point for building CTE queries. + * + * @param The result type which is returned afte the CTE builder + * @author Christian Beikov + * @since 1.1.0 + */ +public interface SelectRecursiveCTECriteriaBuilder extends SelectBaseCTECriteriaBuilder> { + + /** + * Finishes the CTE builder for the non-recursive part and starts the builder for the recursive part. + * The union operator is used for connecting the non-recursive and recursive part, thus removing duplicates. + * + * @return The parent query builder + */ + public SelectCTECriteriaBuilder union(); + + /** + * Finishes the CTE builder for the non-recursive part and starts the builder for the recursive part. + * The union all operator is used for connecting the non-recursive and recursive part, thus not removing duplicates. + * + * @return The parent query builder + */ + public SelectCTECriteriaBuilder unionAll(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/SetOperationBuilder.java b/core/api/src/main/java/com/blazebit/persistence/SetOperationBuilder.java index e82dfb1ba3..ae351000fb 100644 --- a/core/api/src/main/java/com/blazebit/persistence/SetOperationBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/SetOperationBuilder.java @@ -1,112 +1,112 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface SetOperationBuilder> { - - /** - * Connects this query with the union operator with query following after this call. - * - * @return The query builder that should be connected via union - */ - public X union(); - - /** - * Connects this query with the union all operator with query following after this call. - * - * @return The query builder that should be connected via union - */ - public X unionAll(); - - /** - * Connects this query with the intersect operator with query following after this call. - * - * @return The query builder that should be connected via union - */ - public X intersect(); - - /** - * Connects this query with the intersect all operator with query following after this call. - * - * @return The query builder that should be connected via union - */ - public X intersectAll(); - - /** - * Connects this query with the except operator with query following after this call. - * - * @return The query builder that should be connected via union - */ - public X except(); - - /** - * Connects this query with the except all operator with query following after this call. - * - * @return The query builder that should be connected via union - */ - public X exceptAll(); - - /* Subquery variants */ - - /** - * Connects this query with the union operator with subquery following after this call. - * - * @return The query builder that should be connected via union - */ - public Y startUnion(); - - /** - * Connects this query with the union all operator with subquery following after this call. - * - * @return The query builder that should be connected via union - */ - public Y startUnionAll(); - - /** - * Connects this query with the intersect operator with subquery following after this call. - * - * @return The query builder that should be connected via union - */ - public Y startIntersect(); - - /** - * Connects this query with the intersect all operator with subquery following after this call. - * - * @return The query builder that should be connected via union - */ - public Y startIntersectAll(); - - /** - * Connects this query with the except operator with subquery following after this call. - * - * @return The query builder that should be connected via union - */ - public Y startExcept(); - - /** - * Connects this query with the except all operator with subquery following after this call. - * - * @return The query builder that should be connected via union - */ - public Y startExceptAll(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface SetOperationBuilder> { + + /** + * Connects this query with the union operator with query following after this call. + * + * @return The query builder that should be connected via union + */ + public X union(); + + /** + * Connects this query with the union all operator with query following after this call. + * + * @return The query builder that should be connected via union + */ + public X unionAll(); + + /** + * Connects this query with the intersect operator with query following after this call. + * + * @return The query builder that should be connected via union + */ + public X intersect(); + + /** + * Connects this query with the intersect all operator with query following after this call. + * + * @return The query builder that should be connected via union + */ + public X intersectAll(); + + /** + * Connects this query with the except operator with query following after this call. + * + * @return The query builder that should be connected via union + */ + public X except(); + + /** + * Connects this query with the except all operator with query following after this call. + * + * @return The query builder that should be connected via union + */ + public X exceptAll(); + + /* Subquery variants */ + + /** + * Connects this query with the union operator with subquery following after this call. + * + * @return The query builder that should be connected via union + */ + public Y startUnion(); + + /** + * Connects this query with the union all operator with subquery following after this call. + * + * @return The query builder that should be connected via union + */ + public Y startUnionAll(); + + /** + * Connects this query with the intersect operator with subquery following after this call. + * + * @return The query builder that should be connected via union + */ + public Y startIntersect(); + + /** + * Connects this query with the intersect all operator with subquery following after this call. + * + * @return The query builder that should be connected via union + */ + public Y startIntersectAll(); + + /** + * Connects this query with the except operator with subquery following after this call. + * + * @return The query builder that should be connected via union + */ + public Y startExcept(); + + /** + * Connects this query with the except all operator with subquery following after this call. + * + * @return The query builder that should be connected via union + */ + public Y startExceptAll(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationBuilder.java b/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationBuilder.java index 345f608612..2484de4deb 100644 --- a/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationBuilder.java @@ -1,29 +1,29 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface StartOngoingSetOperationBuilder> extends BaseOngoingSetOperationBuilder { - - // TODO: documentation - public Z startSet(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface StartOngoingSetOperationBuilder> extends BaseOngoingSetOperationBuilder { + + // TODO: documentation + public Z startSet(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationCTECriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationCTECriteriaBuilder.java index 526ad5a60e..326175c31f 100644 --- a/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationCTECriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationCTECriteriaBuilder.java @@ -1,26 +1,26 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface StartOngoingSetOperationCTECriteriaBuilder extends OngoingSetOperationCTECriteriaBuilder, StartOngoingSetOperationBuilder, Y, StartOngoingSetOperationCTECriteriaBuilder>> { -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface StartOngoingSetOperationCTECriteriaBuilder extends OngoingSetOperationCTECriteriaBuilder, StartOngoingSetOperationBuilder, Y, StartOngoingSetOperationCTECriteriaBuilder>> { +} diff --git a/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationCriteriaBuilder.java index a88621b878..57320a398d 100644 --- a/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationCriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface StartOngoingSetOperationCriteriaBuilder extends OngoingSetOperationCriteriaBuilder, StartOngoingSetOperationBuilder, Y, StartOngoingSetOperationCriteriaBuilder>> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface StartOngoingSetOperationCriteriaBuilder extends OngoingSetOperationCriteriaBuilder, StartOngoingSetOperationBuilder, Y, StartOngoingSetOperationCriteriaBuilder>> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationSubqueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationSubqueryBuilder.java index 424f424583..fc47de2e12 100644 --- a/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationSubqueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/StartOngoingSetOperationSubqueryBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * An interface for builders that support set operators. - * - * @param The concrete builder type - * @author Christian Beikov - * @since 1.1.0 - */ -public interface StartOngoingSetOperationSubqueryBuilder extends OngoingSetOperationSubqueryBuilder, StartOngoingSetOperationBuilder, Y, StartOngoingSetOperationSubqueryBuilder>> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * An interface for builders that support set operators. + * + * @param The concrete builder type + * @author Christian Beikov + * @since 1.1.0 + */ +public interface StartOngoingSetOperationSubqueryBuilder extends OngoingSetOperationSubqueryBuilder, StartOngoingSetOperationBuilder, Y, StartOngoingSetOperationSubqueryBuilder>> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/SubqueryBuilder.java b/core/api/src/main/java/com/blazebit/persistence/SubqueryBuilder.java index 964768464b..ee7a40e49d 100644 --- a/core/api/src/main/java/com/blazebit/persistence/SubqueryBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/SubqueryBuilder.java @@ -1,35 +1,35 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - - -/** - * A builder for subquery criteria queries. - * - * @param The parent query builder type - * @author Christian Beikov - * @since 1.0 - */ -public interface SubqueryBuilder extends BaseSubqueryBuilder>, SetOperationBuilder, StartOngoingSetOperationSubqueryBuilder>> { - - /** - * Finishes the subquery builder. - * - * @return The parent query builder - */ - public T end(); - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + + +/** + * A builder for subquery criteria queries. + * + * @param The parent query builder type + * @author Christian Beikov + * @since 1.0 + */ +public interface SubqueryBuilder extends BaseSubqueryBuilder>, SetOperationBuilder, StartOngoingSetOperationSubqueryBuilder>> { + + /** + * Finishes the subquery builder. + * + * @return The parent query builder + */ + public T end(); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/UpdateCriteriaBuilder.java b/core/api/src/main/java/com/blazebit/persistence/UpdateCriteriaBuilder.java index 45a89bd141..dc0b673cb6 100644 --- a/core/api/src/main/java/com/blazebit/persistence/UpdateCriteriaBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/UpdateCriteriaBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * A builder for update queries. - * - * @param The entity type for which this update query is - * @author Christian Beikov - * @since 1.1.0 - */ -public interface UpdateCriteriaBuilder extends ModificationCriteriaBuilder>, BaseUpdateCriteriaBuilder> { - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * A builder for update queries. + * + * @param The entity type for which this update query is + * @author Christian Beikov + * @since 1.1.0 + */ +public interface UpdateCriteriaBuilder extends ModificationCriteriaBuilder>, BaseUpdateCriteriaBuilder> { + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/WhereAndBuilder.java b/core/api/src/main/java/com/blazebit/persistence/WhereAndBuilder.java index 646eb4db40..e0ea0e1746 100644 --- a/core/api/src/main/java/com/blazebit/persistence/WhereAndBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/WhereAndBuilder.java @@ -1,41 +1,41 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * The builder interface for a where predicate container that connects predicates with the AND operator. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @since 1.0 - */ -public interface WhereAndBuilder extends BaseWhereBuilder> { - - /** - * Finishes the AND predicate and adds it to the parent predicate container represented by the type T. - * - * @return The parent predicate container builder - */ - public T endAnd(); - - /** - * Starts a where or builder which connects it's predicates with the OR operator. - * When the builder finishes, the predicate is added to this predicate container as conjunct. - * - * @return The where or builder - */ - public WhereOrBuilder> whereOr(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * The builder interface for a where predicate container that connects predicates with the AND operator. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @since 1.0 + */ +public interface WhereAndBuilder extends BaseWhereBuilder> { + + /** + * Finishes the AND predicate and adds it to the parent predicate container represented by the type T. + * + * @return The parent predicate container builder + */ + public T endAnd(); + + /** + * Starts a where or builder which connects it's predicates with the OR operator. + * When the builder finishes, the predicate is added to this predicate container as conjunct. + * + * @return The where or builder + */ + public WhereOrBuilder> whereOr(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/WhereOrBuilder.java b/core/api/src/main/java/com/blazebit/persistence/WhereOrBuilder.java index 9ada437769..53babab8bc 100644 --- a/core/api/src/main/java/com/blazebit/persistence/WhereOrBuilder.java +++ b/core/api/src/main/java/com/blazebit/persistence/WhereOrBuilder.java @@ -1,41 +1,41 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence; - -/** - * The builder interface for a where predicate container that connects predicates with the OR operator. - * - * @param The builder type that is returned on terminal operations - * @author Christian Beikov - * @since 1.0 - */ -public interface WhereOrBuilder extends BaseWhereBuilder> { - - /** - * Finishes the OR predicate and adds it to the parent predicate container represented by the type T. - * - * @return The parent predicate container builder - */ - public T endOr(); - - /** - * Starts a where and builder which connects it's predicates with the AND operator. - * When the builder finishes, the predicate is added to this predicate container as disjunct. - * - * @return The where and builder - */ - public WhereAndBuilder> whereAnd(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence; + +/** + * The builder interface for a where predicate container that connects predicates with the OR operator. + * + * @param The builder type that is returned on terminal operations + * @author Christian Beikov + * @since 1.0 + */ +public interface WhereOrBuilder extends BaseWhereBuilder> { + + /** + * Finishes the OR predicate and adds it to the parent predicate container represented by the type T. + * + * @return The parent predicate container builder + */ + public T endOr(); + + /** + * Starts a where and builder which connects it's predicates with the AND operator. + * When the builder finishes, the predicate is added to this predicate container as disjunct. + * + * @return The where and builder + */ + public WhereAndBuilder> whereAnd(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/internal/package-info.java b/core/api/src/main/java/com/blazebit/persistence/internal/package-info.java index f6619919ac..59793e9e31 100644 --- a/core/api/src/main/java/com/blazebit/persistence/internal/package-info.java +++ b/core/api/src/main/java/com/blazebit/persistence/internal/package-info.java @@ -1,22 +1,22 @@ -/* - * Copyright 2015 Blazebit. - * - * 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. - */ - -/** - * Contains experimental extensions that might not be supported by all JPA providers. - * Beware that although the functionality won't disappear, the API might change from time to time. - */ -package com.blazebit.persistence.internal; - +/* + * Copyright 2015 Blazebit. + * + * 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. + */ + +/** + * Contains experimental extensions that might not be supported by all JPA providers. + * Beware that although the functionality won't disappear, the API might change from time to time. + */ +package com.blazebit.persistence.internal; + diff --git a/core/api/src/main/java/com/blazebit/persistence/package-info.java b/core/api/src/main/java/com/blazebit/persistence/package-info.java index aa763edb31..8cd7385295 100644 --- a/core/api/src/main/java/com/blazebit/persistence/package-info.java +++ b/core/api/src/main/java/com/blazebit/persistence/package-info.java @@ -1,21 +1,21 @@ -/* - * Copyright 2015 Blazebit. - * - * 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. - */ - -/** - * Blaze-Persistence is a rich Criteria API for JPA. - */ -package com.blazebit.persistence; - +/* + * Copyright 2015 Blazebit. + * + * 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. + */ + +/** + * Blaze-Persistence is a rich Criteria API for JPA. + */ +package com.blazebit.persistence; + diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfigurationProvider.java b/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfigurationProvider.java index 34fc341d0f..0ef4e8f559 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfigurationProvider.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfigurationProvider.java @@ -1,34 +1,34 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.spi; - -/** - * Interface implemented by the criteria provider. - * - * Implementations are instantiated via {@link java.util.ServiceLoader}. - * - * @author Christian Beikov - * @since 1.0 - */ -public interface CriteriaBuilderConfigurationProvider { - - /** - * Creates and returns a new criteria builder configuration. - * - * @return A new criteria builder configuration - */ - public CriteriaBuilderConfiguration createConfiguration(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.spi; + +/** + * Interface implemented by the criteria provider. + * + * Implementations are instantiated via {@link java.util.ServiceLoader}. + * + * @author Christian Beikov + * @since 1.0 + */ +public interface CriteriaBuilderConfigurationProvider { + + /** + * Creates and returns a new criteria builder configuration. + * + * @return A new criteria builder configuration + */ + public CriteriaBuilderConfiguration createConfiguration(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/CteQueryWrapper.java b/core/api/src/main/java/com/blazebit/persistence/spi/CteQueryWrapper.java index 37185f0983..435ce386fa 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/CteQueryWrapper.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/CteQueryWrapper.java @@ -1,34 +1,34 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.spi; - -import java.util.List; - -import javax.persistence.Query; - - - -/** - * Interface for CTE queries - * - * @author Christian Beikov - * @since 1.1.0 - */ -public interface CteQueryWrapper { - - public List getParticipatingQueries(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.spi; + +import java.util.List; + +import javax.persistence.Query; + + + +/** + * Interface for CTE queries + * + * @author Christian Beikov + * @since 1.1.0 + */ +public interface CteQueryWrapper { + + public List getParticipatingQueries(); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/FunctionRenderContext.java b/core/api/src/main/java/com/blazebit/persistence/spi/FunctionRenderContext.java index bc050a4647..074d294df8 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/FunctionRenderContext.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/FunctionRenderContext.java @@ -1,58 +1,58 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.spi; - -/** - * Interface implemented by the criteria provider. - * - * Abstraction to allow building structured output. This is used for rendering - * dbms specific code for a {@link JpqlFunction}. - * - * @author Christian Beikov - * @since 1.0 - */ -public interface FunctionRenderContext { - - /** - * Returns the size of the arguments given to this function. - * - * @return the size of function arguments - */ - public int getArgumentsSize(); - - /** - * Returns the string representation of the argument at the given index. - * - * @param index The index of the wanted argument - * @return the string representation of the wanted argument - */ - public String getArgument(int index); - - /** - * Adds a binding to the argument of the given index to the render context. - * - * @param index The index of the wanted argument - */ - public void addArgument(int index); - - /** - * Adds the given chunk to the render context. - * - * @param chunk The chunk to add - */ - public void addChunk(String chunk); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.spi; + +/** + * Interface implemented by the criteria provider. + * + * Abstraction to allow building structured output. This is used for rendering + * dbms specific code for a {@link JpqlFunction}. + * + * @author Christian Beikov + * @since 1.0 + */ +public interface FunctionRenderContext { + + /** + * Returns the size of the arguments given to this function. + * + * @return the size of function arguments + */ + public int getArgumentsSize(); + + /** + * Returns the string representation of the argument at the given index. + * + * @param index The index of the wanted argument + * @return the string representation of the wanted argument + */ + public String getArgument(int index); + + /** + * Adds a binding to the argument of the given index to the render context. + * + * @param index The index of the wanted argument + */ + public void addArgument(int index); + + /** + * Adds the given chunk to the render context. + * + * @param chunk The chunk to add + */ + public void addChunk(String chunk); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/JpqlFunctionGroup.java b/core/api/src/main/java/com/blazebit/persistence/spi/JpqlFunctionGroup.java index d2196faa69..ccba6cc6ef 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/JpqlFunctionGroup.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/JpqlFunctionGroup.java @@ -1,50 +1,50 @@ -package com.blazebit.persistence.spi; - -import java.util.HashMap; -import java.util.Map; - -public final class JpqlFunctionGroup { - - private final String name; - private final boolean aggregate; - private final Map rdbmsFunctions; - - public JpqlFunctionGroup(String name) { - this(name, false); - } - - public JpqlFunctionGroup(String name, JpqlFunction defaultFunction) { - this(name, false); - add(null, defaultFunction); - } - - public JpqlFunctionGroup(String name, boolean aggregate) { - this(name, aggregate, new HashMap()); - } - - public JpqlFunctionGroup(String name, boolean aggregate, Map rdbmsFunctions) { - this.name = name; - this.aggregate = aggregate; - this.rdbmsFunctions = new HashMap(rdbmsFunctions); - } - - public String getName() { - return name; - } - - public boolean isAggregate() { - return aggregate; - } - - public JpqlFunction get(String rdbms) { - return rdbmsFunctions.get(rdbms); - } - - public boolean contains(String rdbms) { - return rdbmsFunctions.containsKey(rdbms); - } - - public void add(String rdbms, JpqlFunction function) { - rdbmsFunctions.put(rdbms, function); - } -} +package com.blazebit.persistence.spi; + +import java.util.HashMap; +import java.util.Map; + +public final class JpqlFunctionGroup { + + private final String name; + private final boolean aggregate; + private final Map rdbmsFunctions; + + public JpqlFunctionGroup(String name) { + this(name, false); + } + + public JpqlFunctionGroup(String name, JpqlFunction defaultFunction) { + this(name, false); + add(null, defaultFunction); + } + + public JpqlFunctionGroup(String name, boolean aggregate) { + this(name, aggregate, new HashMap()); + } + + public JpqlFunctionGroup(String name, boolean aggregate, Map rdbmsFunctions) { + this.name = name; + this.aggregate = aggregate; + this.rdbmsFunctions = new HashMap(rdbmsFunctions); + } + + public String getName() { + return name; + } + + public boolean isAggregate() { + return aggregate; + } + + public JpqlFunction get(String rdbms) { + return rdbmsFunctions.get(rdbms); + } + + public boolean contains(String rdbms) { + return rdbmsFunctions.containsKey(rdbms); + } + + public void add(String rdbms, JpqlFunction function) { + rdbmsFunctions.put(rdbms, function); + } +} diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/OrderByElement.java b/core/api/src/main/java/com/blazebit/persistence/spi/OrderByElement.java index ba98a6e0f0..2adef4ea7f 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/OrderByElement.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/OrderByElement.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.spi; - - -/** - * Represents an order by element. - * - * @author Christian Beikov - * @since 1.1.0 - */ -public interface OrderByElement { - - public int getPosition(); - - public boolean isAscending(); - - public boolean isNullsFirst(); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.spi; + + +/** + * Represents an order by element. + * + * @author Christian Beikov + * @since 1.1.0 + */ +public interface OrderByElement { + + public int getPosition(); + + public boolean isAscending(); + + public boolean isNullsFirst(); + +} diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/QueryTransformer.java b/core/api/src/main/java/com/blazebit/persistence/spi/QueryTransformer.java index 00b0ab2430..742da823df 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/QueryTransformer.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/QueryTransformer.java @@ -1,40 +1,40 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.spi; - -import com.blazebit.persistence.ObjectBuilder; -import javax.persistence.TypedQuery; - -/** - * Interface implemented by the criteria provider. - * - * It is invoked to transform a JPA query. - * - * @author Christian Beikov - * @since 1.0 - */ -public interface QueryTransformer { - - /** - * Transforms the query. - * - * @param The query result type - * @param query The original query - * @param objectBuilder The object build that should be used to transform the query - * @return The transformed query - */ - public TypedQuery transformQuery(TypedQuery query, ObjectBuilder objectBuilder); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.spi; + +import com.blazebit.persistence.ObjectBuilder; +import javax.persistence.TypedQuery; + +/** + * Interface implemented by the criteria provider. + * + * It is invoked to transform a JPA query. + * + * @author Christian Beikov + * @since 1.0 + */ +public interface QueryTransformer { + + /** + * Transforms the query. + * + * @param The query result type + * @param query The original query + * @param objectBuilder The object build that should be used to transform the query + * @return The transformed query + */ + public TypedQuery transformQuery(TypedQuery query, ObjectBuilder objectBuilder); +} diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/SetOperationType.java b/core/api/src/main/java/com/blazebit/persistence/spi/SetOperationType.java index a8e960e206..a35a02e781 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/SetOperationType.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/SetOperationType.java @@ -1,11 +1,11 @@ -package com.blazebit.persistence.spi; - - -public enum SetOperationType { - UNION, - UNION_ALL, - INTERSECT, - INTERSECT_ALL, - EXCEPT, - EXCEPT_ALL; +package com.blazebit.persistence.spi; + + +public enum SetOperationType { + UNION, + UNION_ALL, + INTERSECT, + INTERSECT_ALL, + EXCEPT, + EXCEPT_ALL; } \ No newline at end of file diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/TemplateRenderer.java b/core/api/src/main/java/com/blazebit/persistence/spi/TemplateRenderer.java index 19db9b0ff9..5ff9e469b7 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/TemplateRenderer.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/TemplateRenderer.java @@ -1,166 +1,166 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.spi; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -/** - * A template renderer is a thread safe string renderer that can bind values to parameters. - * It is not as sophisticated as {@link MessageFormat} but in contrast can be shared between threads - * because it is immutable. Parameters are denoted by a question mark directly followed by the parameter index. - * - * The following example should illustrate the usage. - * - * - * new TemplateRenderer("?1 limit ?2") - * .start(context) - * .addArgument(1) - * .addArgument(2) - * .build(); - * - * - * @author Christian Beikov - * @since 1.0.6 - */ -public class TemplateRenderer { - - private final String[] chunks; - private final Integer[] parameterIndices; - - /** - * Creates a new template renderer from the given template. - * - * @param template The template on which this renderer is based. - */ - public TemplateRenderer(String template) { - List chunkList = new ArrayList(); - List parameterIndexList = new ArrayList(); - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < template.length(); i++) { - char c = template.charAt(i); - - if (c == '?') { - chunkList.add(sb.toString()); - sb.setLength(0); - - while (++i < template.length()) { - c = template.charAt(i); - if (Character.isDigit(c)) { - sb.append(c); - } else { - parameterIndexList.add(Integer.valueOf(sb.toString()) - 1); - sb.setLength(0); - sb.append(c); - break; - } - } - - if (i == template.length()) { - parameterIndexList.add(Integer.valueOf(sb.toString()) - 1); - sb.setLength(0); - } - } else { - sb.append(c); - } - } - - if (sb.length() > 0) { - chunkList.add(sb.toString()); - } - - this.chunks = chunkList.toArray(new String[chunkList.size()]); - this.parameterIndices = parameterIndexList.toArray(new Integer[parameterIndexList.size()]); - } - - /** - * Starts a new context for the given {@linkplain FunctionRenderContext} for building parameter bindings. - * - * @param context The render context for the function - * @return A context for binding parameter values - */ - public Context start(FunctionRenderContext context) { - return new Context(this, context); - } - - public static class Context { - - private final TemplateRenderer template; - private final FunctionRenderContext context; - private final Object[] boundValues; - private int boundValueIndex = 0; - - public Context(TemplateRenderer template, FunctionRenderContext context) { - this.template = template; - this.context = context; - this.boundValues = new Object[template.parameterIndices.length]; - } - - /** - * Uses the value of the argument at the given index as value to be bound to the current parameter. - * - * @param index The index of the argument - * @return This context for chaining - */ - public Context addArgument(int index) { - if (boundValueIndex >= boundValues.length) { - throw new IllegalArgumentException("The index " + boundValueIndex + " is invalid since all parameters have already been bound."); - } - - boundValues[boundValueIndex++] = index; - return this; - } - - /** - * Uses the given chunk as value to be bound to the current parameter. - * - * @param chunk The chunk to use as value - * @return This context for chaining - */ - public Context addParameter(String chunk) { - if (boundValueIndex >= boundValues.length) { - throw new IllegalArgumentException("The index " + boundValueIndex + " is invalid since all parameters have already been bound."); - } - - boundValues[boundValueIndex++] = chunk; - return this; - } - - /** - * Binds the values to the underlying {@link FunctionRenderContext}. - */ - public void build() { - String[] chunks = template.chunks; - Integer[] parameterIndices = template.parameterIndices; - for (int i = 0; i < chunks.length; i++) { - context.addChunk(chunks[i]); - - if (i < parameterIndices.length) { - int parameterIndex = parameterIndices[i]; - Object boundValue = boundValues[parameterIndex]; - - if (boundValue instanceof Integer) { - context.addArgument((Integer) boundValue); - } else { - context.addChunk(boundValue.toString()); - } - } - } - } - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.spi; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * A template renderer is a thread safe string renderer that can bind values to parameters. + * It is not as sophisticated as {@link MessageFormat} but in contrast can be shared between threads + * because it is immutable. Parameters are denoted by a question mark directly followed by the parameter index. + * + * The following example should illustrate the usage. + * + * + * new TemplateRenderer("?1 limit ?2") + * .start(context) + * .addArgument(1) + * .addArgument(2) + * .build(); + * + * + * @author Christian Beikov + * @since 1.0.6 + */ +public class TemplateRenderer { + + private final String[] chunks; + private final Integer[] parameterIndices; + + /** + * Creates a new template renderer from the given template. + * + * @param template The template on which this renderer is based. + */ + public TemplateRenderer(String template) { + List chunkList = new ArrayList(); + List parameterIndexList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < template.length(); i++) { + char c = template.charAt(i); + + if (c == '?') { + chunkList.add(sb.toString()); + sb.setLength(0); + + while (++i < template.length()) { + c = template.charAt(i); + if (Character.isDigit(c)) { + sb.append(c); + } else { + parameterIndexList.add(Integer.valueOf(sb.toString()) - 1); + sb.setLength(0); + sb.append(c); + break; + } + } + + if (i == template.length()) { + parameterIndexList.add(Integer.valueOf(sb.toString()) - 1); + sb.setLength(0); + } + } else { + sb.append(c); + } + } + + if (sb.length() > 0) { + chunkList.add(sb.toString()); + } + + this.chunks = chunkList.toArray(new String[chunkList.size()]); + this.parameterIndices = parameterIndexList.toArray(new Integer[parameterIndexList.size()]); + } + + /** + * Starts a new context for the given {@linkplain FunctionRenderContext} for building parameter bindings. + * + * @param context The render context for the function + * @return A context for binding parameter values + */ + public Context start(FunctionRenderContext context) { + return new Context(this, context); + } + + public static class Context { + + private final TemplateRenderer template; + private final FunctionRenderContext context; + private final Object[] boundValues; + private int boundValueIndex = 0; + + public Context(TemplateRenderer template, FunctionRenderContext context) { + this.template = template; + this.context = context; + this.boundValues = new Object[template.parameterIndices.length]; + } + + /** + * Uses the value of the argument at the given index as value to be bound to the current parameter. + * + * @param index The index of the argument + * @return This context for chaining + */ + public Context addArgument(int index) { + if (boundValueIndex >= boundValues.length) { + throw new IllegalArgumentException("The index " + boundValueIndex + " is invalid since all parameters have already been bound."); + } + + boundValues[boundValueIndex++] = index; + return this; + } + + /** + * Uses the given chunk as value to be bound to the current parameter. + * + * @param chunk The chunk to use as value + * @return This context for chaining + */ + public Context addParameter(String chunk) { + if (boundValueIndex >= boundValues.length) { + throw new IllegalArgumentException("The index " + boundValueIndex + " is invalid since all parameters have already been bound."); + } + + boundValues[boundValueIndex++] = chunk; + return this; + } + + /** + * Binds the values to the underlying {@link FunctionRenderContext}. + */ + public void build() { + String[] chunks = template.chunks; + Integer[] parameterIndices = template.parameterIndices; + for (int i = 0; i < chunks.length; i++) { + context.addChunk(chunks[i]); + + if (i < parameterIndices.length) { + int parameterIndex = parameterIndices[i]; + Object boundValue = boundValues[parameterIndex]; + + if (boundValue instanceof Integer) { + context.addArgument((Integer) boundValue); + } else { + context.addChunk(boundValue.toString()); + } + } + } + } + } +} diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/package-info.java b/core/api/src/main/java/com/blazebit/persistence/spi/package-info.java index 69375c66c1..9dda953937 100644 --- a/core/api/src/main/java/com/blazebit/persistence/spi/package-info.java +++ b/core/api/src/main/java/com/blazebit/persistence/spi/package-info.java @@ -1,21 +1,21 @@ -/* - * Copyright 2015 Blazebit. - * - * 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. - */ - -/** - * SPI for implementers of the Blaze-Persistence API. - */ -package com.blazebit.persistence.spi; - +/* + * Copyright 2015 Blazebit. + * + * 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. + */ + +/** + * SPI for implementers of the Blaze-Persistence API. + */ +package com.blazebit.persistence.spi; + diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbortableOnClauseJoinNodeVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbortableOnClauseJoinNodeVisitor.java index 5b759db13e..510b09f264 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbortableOnClauseJoinNodeVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbortableOnClauseJoinNodeVisitor.java @@ -1,49 +1,49 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @since 1.0.5 - */ -public class AbortableOnClauseJoinNodeVisitor implements AbortableResultJoinNodeVisitor { - - private final Expression.ResultVisitor visitor; - private final Boolean stopValue; - - public AbortableOnClauseJoinNodeVisitor(Expression.ResultVisitor visitor, Boolean stopValue) { - this.visitor = visitor; - this.stopValue = stopValue; - } - - @Override - public Boolean visit(JoinNode node) { - if (node.getOnPredicate() != null) { - return node.getOnPredicate().accept(visitor); - } - - return null; - } - - public Boolean getStopValue() { - return stopValue; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @since 1.0.5 + */ +public class AbortableOnClauseJoinNodeVisitor implements AbortableResultJoinNodeVisitor { + + private final Expression.ResultVisitor visitor; + private final Boolean stopValue; + + public AbortableOnClauseJoinNodeVisitor(Expression.ResultVisitor visitor, Boolean stopValue) { + this.visitor = visitor; + this.stopValue = stopValue; + } + + @Override + public Boolean visit(JoinNode node) { + if (node.getOnPredicate() != null) { + return node.getOnPredicate().accept(visitor); + } + + return null; + } + + public Boolean getStopValue() { + return stopValue; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbortableResultJoinNodeVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbortableResultJoinNodeVisitor.java index 6f63e41bcd..a0b2069859 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbortableResultJoinNodeVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbortableResultJoinNodeVisitor.java @@ -1,27 +1,27 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -/** - * - * @author Christian Beikov - * @since 1.0.5 - */ -public interface AbortableResultJoinNodeVisitor extends ResultJoinNodeVisitor { - - public T getStopValue(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +/** + * + * @author Christian Beikov + * @since 1.0.5 + */ +public interface AbortableResultJoinNodeVisitor extends ResultJoinNodeVisitor { + + public T getStopValue(); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCriteriaBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCriteriaBuilder.java index 35a1a04da1..b527ee54fa 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCriteriaBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCriteriaBuilder.java @@ -1,77 +1,77 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.BaseCriteriaBuilder; -import com.blazebit.persistence.spi.DbmsStatementType; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @param The criteria builder returned after the cte builder - * @param The concrete builder type - * @param The builder type that should be returned on set operations - * @author Christian Beikov - * @since 1.1.0 - */ -public abstract class AbstractCriteriaBuilder, Z, W> extends AbstractCommonQueryBuilder> { - - protected final BuilderListener listener; - protected final BuilderListenerImpl subListener; - - public AbstractCriteriaBuilder(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias, BuilderListener listener, BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { - super(mainQuery, isMainQuery, DbmsStatementType.SELECT, clazz, alias, finalSetOperationBuilder); - this.listener = listener; - this.subListener = new BuilderListenerImpl(); - } - - public BuilderListenerImpl getSubListener() { - return subListener; - } - - protected BaseFinalSetOperationCriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested, boolean isSubquery) { - boolean wasMainQuery = isMainQuery; - this.isMainQuery = false; - BuilderListener newListener = finalSetOperationBuilder == null ? null : finalSetOperationBuilder.getSubListener(); - - if (isSubquery) { - return new OngoingFinalSetOperationCriteriaBuilderImpl(mainQuery, wasMainQuery, resultType, operator, nested, newListener); - } else { - return new FinalSetOperationCriteriaBuilderImpl(mainQuery, wasMainQuery, resultType, operator, nested, newListener); - } - } - - @SuppressWarnings("unchecked") - protected LeafOngoingSetOperationCriteriaBuilderImpl createLeaf(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { - BuilderListener newListener = finalSetOperationBuilder.getSubListener(); - LeafOngoingSetOperationCriteriaBuilderImpl next = new LeafOngoingSetOperationCriteriaBuilderImpl(mainQuery, false, resultType, newListener, (FinalSetOperationCriteriaBuilderImpl) finalSetOperationBuilder); - newListener.onBuilderStarted(next); - return next; - } - - @SuppressWarnings("unchecked") - protected OngoingSetOperationCriteriaBuilderImpl createOngoing(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, Y endSetResult) { - // TODO: This is such an ugly hack, but I don't know how else to fix this generics issue for now - finalSetOperationBuilder.setEndSetResult((T) endSetResult); - - BuilderListener newListener = finalSetOperationBuilder.getSubListener(); - OngoingSetOperationCriteriaBuilderImpl next = new OngoingSetOperationCriteriaBuilderImpl(mainQuery, false, resultType, newListener, (OngoingFinalSetOperationCriteriaBuilderImpl) finalSetOperationBuilder, endSetResult); - newListener.onBuilderStarted(next); - return next; - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.BaseCriteriaBuilder; +import com.blazebit.persistence.spi.DbmsStatementType; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @param The criteria builder returned after the cte builder + * @param The concrete builder type + * @param The builder type that should be returned on set operations + * @author Christian Beikov + * @since 1.1.0 + */ +public abstract class AbstractCriteriaBuilder, Z, W> extends AbstractCommonQueryBuilder> { + + protected final BuilderListener listener; + protected final BuilderListenerImpl subListener; + + public AbstractCriteriaBuilder(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias, BuilderListener listener, BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { + super(mainQuery, isMainQuery, DbmsStatementType.SELECT, clazz, alias, finalSetOperationBuilder); + this.listener = listener; + this.subListener = new BuilderListenerImpl(); + } + + public BuilderListenerImpl getSubListener() { + return subListener; + } + + protected BaseFinalSetOperationCriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested, boolean isSubquery) { + boolean wasMainQuery = isMainQuery; + this.isMainQuery = false; + BuilderListener newListener = finalSetOperationBuilder == null ? null : finalSetOperationBuilder.getSubListener(); + + if (isSubquery) { + return new OngoingFinalSetOperationCriteriaBuilderImpl(mainQuery, wasMainQuery, resultType, operator, nested, newListener); + } else { + return new FinalSetOperationCriteriaBuilderImpl(mainQuery, wasMainQuery, resultType, operator, nested, newListener); + } + } + + @SuppressWarnings("unchecked") + protected LeafOngoingSetOperationCriteriaBuilderImpl createLeaf(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { + BuilderListener newListener = finalSetOperationBuilder.getSubListener(); + LeafOngoingSetOperationCriteriaBuilderImpl next = new LeafOngoingSetOperationCriteriaBuilderImpl(mainQuery, false, resultType, newListener, (FinalSetOperationCriteriaBuilderImpl) finalSetOperationBuilder); + newListener.onBuilderStarted(next); + return next; + } + + @SuppressWarnings("unchecked") + protected OngoingSetOperationCriteriaBuilderImpl createOngoing(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, Y endSetResult) { + // TODO: This is such an ugly hack, but I don't know how else to fix this generics issue for now + finalSetOperationBuilder.setEndSetResult((T) endSetResult); + + BuilderListener newListener = finalSetOperationBuilder.getSubListener(); + OngoingSetOperationCriteriaBuilderImpl next = new OngoingSetOperationCriteriaBuilderImpl(mainQuery, false, resultType, newListener, (OngoingFinalSetOperationCriteriaBuilderImpl) finalSetOperationBuilder, endSetResult); + newListener.onBuilderStarted(next); + return next; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractFullQueryBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractFullQueryBuilder.java index 790cc4f04f..9865307589 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractFullQueryBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractFullQueryBuilder.java @@ -1,269 +1,269 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.lang.reflect.Constructor; - -import javax.persistence.metamodel.EntityType; - -import com.blazebit.persistence.FullQueryBuilder; -import com.blazebit.persistence.JoinType; -import com.blazebit.persistence.KeysetPage; -import com.blazebit.persistence.ObjectBuilder; -import com.blazebit.persistence.PaginatedCriteriaBuilder; -import com.blazebit.persistence.SelectObjectBuilder; - -/** - * - * @param The query result type - * @param The concrete builder type - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public abstract class AbstractFullQueryBuilder, Z, W, FinalSetReturn extends BaseFinalSetOperationBuilderImpl> extends AbstractQueryBuilder implements FullQueryBuilder { - - /** - * This flag indicates whether the current builder has been used to create a - * PaginatedCriteriaBuilder. In this case we must not allow any calls to - * group by and distinct since the corresponding managers are shared with - * the PaginatedCriteriaBuilder and any changes would affect the - * PaginatedCriteriaBuilder as well. - */ - private boolean createdPaginatedBuilder = false; - - /** - * Create flat copy of builder - * - * @param builder - */ - protected AbstractFullQueryBuilder(AbstractFullQueryBuilder, ?, ?, ?> builder) { - super(builder); - } - - public AbstractFullQueryBuilder(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias, FinalSetReturn finalSetOperationBuilder) { - super(mainQuery, isMainQuery, clazz, alias, finalSetOperationBuilder); - } - - @Override - public PaginatedCriteriaBuilder page(int firstRow, int pageSize) { - clearCache(); - if (selectManager.isDistinct()) { - throw new IllegalStateException("Cannot paginate a DISTINCT query"); - } - if (!groupByManager.isEmpty()) { - throw new IllegalStateException("Cannot paginate a GROUP BY query"); - } - createdPaginatedBuilder = true; - return new PaginatedCriteriaBuilderImpl(this, false, null, firstRow, pageSize); - } - - @Override - public PaginatedCriteriaBuilder page(Object entityId, int pageSize) { - clearCache(); - if (selectManager.isDistinct()) { - throw new IllegalStateException("Cannot paginate a DISTINCT query"); - } - if (!groupByManager.isEmpty()) { - throw new IllegalStateException("Cannot paginate a GROUP BY query"); - } - checkEntityId(entityId); - createdPaginatedBuilder = true; - return new PaginatedCriteriaBuilderImpl(this, false, null, entityId, pageSize); - } - - @Override - public PaginatedCriteriaBuilder page(KeysetPage keysetPage, int firstRow, int pageSize) { - clearCache(); - if (selectManager.isDistinct()) { - throw new IllegalStateException("Cannot paginate a DISTINCT query"); - } - if (!groupByManager.isEmpty()) { - throw new IllegalStateException("Cannot paginate a GROUP BY query"); - } - createdPaginatedBuilder = true; - return new PaginatedCriteriaBuilderImpl(this, true, keysetPage, firstRow, pageSize); - } - - private void checkEntityId(Object entityId) { - if (entityId == null) { - throw new IllegalArgumentException("Invalid null entity id given"); - } - - EntityType entityType = em.getMetamodel().entity(joinManager.getRootNodeOrFail("Paginated queries do not support multiple from clause elements!").getPropertyClass()); - Class idType = entityType.getIdType().getJavaType(); - - if (!idType.isInstance(entityId)) { - throw new IllegalArgumentException("The type of the given entity id '" + entityId.getClass().getName() - + "' is not an instance of the expected id type '" + idType.getName() + "' of the entity class '" + entityType.getJavaType().getName() + "'"); - } - } - - @Override - public SelectObjectBuilder> selectNew(Class clazz) { - clearCache(); - if (clazz == null) { - throw new NullPointerException("clazz"); - } - - verifyBuilderEnded(); - return selectManager.selectNew(this, clazz); - } - - @Override - public SelectObjectBuilder> selectNew(Constructor constructor) { - clearCache(); - if (constructor == null) { - throw new NullPointerException("constructor"); - } - - verifyBuilderEnded(); - return selectManager.selectNew(this, constructor); - } - - @Override - @SuppressWarnings("unchecked") - public FullQueryBuilder selectNew(ObjectBuilder objectBuilder) { - clearCache(); - if (objectBuilder == null) { - throw new NullPointerException("objectBuilder"); - } - - verifyBuilderEnded(); - selectManager.selectNew((X) this, objectBuilder); - return (FullQueryBuilder) this; - } - - private void checkFetchJoinAllowed() { - if (selectManager.getSelectInfos().size() > 0) { - throw new IllegalStateException("Fetch joins are only possible if the root entity is selected"); - } - } - - @Override - @SuppressWarnings("unchecked") - public X fetch(String path) { - clearCache(); - checkFetchJoinAllowed(); - verifyBuilderEnded(); - joinManager.implicitJoin(expressionFactory.createSimpleExpression(path), true, null, false, false, true, true); - return (X) this; - } - - @Override - @SuppressWarnings("unchecked") - public X fetch(String... paths) { - clearCache(); - checkFetchJoinAllowed(); - verifyBuilderEnded(); - - for (String path : paths) { - joinManager.implicitJoin(expressionFactory.createSimpleExpression(path), true, null, false, false, true, true); - } - - return (X) this; - } - - @Override - public X innerJoinFetch(String path, String alias) { - return join(path, alias, JoinType.INNER, true); - } - - @Override - public X innerJoinFetchDefault(String path, String alias) { - return joinDefault(path, alias, JoinType.INNER, true); - } - - @Override - public X leftJoinFetch(String path, String alias) { - return join(path, alias, JoinType.LEFT, true); - } - - @Override - public X leftJoinFetchDefault(String path, String alias) { - return joinDefault(path, alias, JoinType.LEFT, true); - } - - @Override - public X rightJoinFetch(String path, String alias) { - return join(path, alias, JoinType.RIGHT, true); - } - - @Override - public X rightJoinFetchDefault(String path, String alias) { - return joinDefault(path, alias, JoinType.RIGHT, true); - } - - @Override - public X join(String path, String alias, JoinType type, boolean fetch) { - return join(path, alias, type, fetch, false); - } - - @Override - public X joinDefault(String path, String alias, JoinType type, boolean fetch) { - return join(path, alias, type, fetch, true); - } - - @SuppressWarnings("unchecked") - private X join(String path, String alias, JoinType type, boolean fetch, boolean defaultJoin) { - clearCache(); - if (path == null) { - throw new NullPointerException("path"); - } - if (alias == null) { - throw new NullPointerException("alias"); - } - if (type == null) { - throw new NullPointerException("type"); - } - if (alias.isEmpty()) { - throw new IllegalArgumentException("Empty alias"); - } - - if (fetch == true) { - checkFetchJoinAllowed(); - } - - verifyBuilderEnded(); - joinManager.join(path, alias, type, fetch, defaultJoin); - return (X) this; - } - - @Override - public X groupBy(String expression) { - if (createdPaginatedBuilder) { - throw new IllegalStateException("Calling groupBy() on a PaginatedCriteriaBuilder is not allowed."); - } - return super.groupBy(expression); - } - - @Override - public X groupBy(String... paths) { - if (createdPaginatedBuilder) { - throw new IllegalStateException("Calling groupBy() on a PaginatedCriteriaBuilder is not allowed."); - } - return super.groupBy(paths); - } - - @Override - public X distinct() { - if (createdPaginatedBuilder) { - throw new IllegalStateException("Calling distinct() on a PaginatedCriteriaBuilder is not allowed."); - } - return super.distinct(); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.lang.reflect.Constructor; + +import javax.persistence.metamodel.EntityType; + +import com.blazebit.persistence.FullQueryBuilder; +import com.blazebit.persistence.JoinType; +import com.blazebit.persistence.KeysetPage; +import com.blazebit.persistence.ObjectBuilder; +import com.blazebit.persistence.PaginatedCriteriaBuilder; +import com.blazebit.persistence.SelectObjectBuilder; + +/** + * + * @param The query result type + * @param The concrete builder type + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public abstract class AbstractFullQueryBuilder, Z, W, FinalSetReturn extends BaseFinalSetOperationBuilderImpl> extends AbstractQueryBuilder implements FullQueryBuilder { + + /** + * This flag indicates whether the current builder has been used to create a + * PaginatedCriteriaBuilder. In this case we must not allow any calls to + * group by and distinct since the corresponding managers are shared with + * the PaginatedCriteriaBuilder and any changes would affect the + * PaginatedCriteriaBuilder as well. + */ + private boolean createdPaginatedBuilder = false; + + /** + * Create flat copy of builder + * + * @param builder + */ + protected AbstractFullQueryBuilder(AbstractFullQueryBuilder, ?, ?, ?> builder) { + super(builder); + } + + public AbstractFullQueryBuilder(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias, FinalSetReturn finalSetOperationBuilder) { + super(mainQuery, isMainQuery, clazz, alias, finalSetOperationBuilder); + } + + @Override + public PaginatedCriteriaBuilder page(int firstRow, int pageSize) { + clearCache(); + if (selectManager.isDistinct()) { + throw new IllegalStateException("Cannot paginate a DISTINCT query"); + } + if (!groupByManager.isEmpty()) { + throw new IllegalStateException("Cannot paginate a GROUP BY query"); + } + createdPaginatedBuilder = true; + return new PaginatedCriteriaBuilderImpl(this, false, null, firstRow, pageSize); + } + + @Override + public PaginatedCriteriaBuilder page(Object entityId, int pageSize) { + clearCache(); + if (selectManager.isDistinct()) { + throw new IllegalStateException("Cannot paginate a DISTINCT query"); + } + if (!groupByManager.isEmpty()) { + throw new IllegalStateException("Cannot paginate a GROUP BY query"); + } + checkEntityId(entityId); + createdPaginatedBuilder = true; + return new PaginatedCriteriaBuilderImpl(this, false, null, entityId, pageSize); + } + + @Override + public PaginatedCriteriaBuilder page(KeysetPage keysetPage, int firstRow, int pageSize) { + clearCache(); + if (selectManager.isDistinct()) { + throw new IllegalStateException("Cannot paginate a DISTINCT query"); + } + if (!groupByManager.isEmpty()) { + throw new IllegalStateException("Cannot paginate a GROUP BY query"); + } + createdPaginatedBuilder = true; + return new PaginatedCriteriaBuilderImpl(this, true, keysetPage, firstRow, pageSize); + } + + private void checkEntityId(Object entityId) { + if (entityId == null) { + throw new IllegalArgumentException("Invalid null entity id given"); + } + + EntityType entityType = em.getMetamodel().entity(joinManager.getRootNodeOrFail("Paginated queries do not support multiple from clause elements!").getPropertyClass()); + Class idType = entityType.getIdType().getJavaType(); + + if (!idType.isInstance(entityId)) { + throw new IllegalArgumentException("The type of the given entity id '" + entityId.getClass().getName() + + "' is not an instance of the expected id type '" + idType.getName() + "' of the entity class '" + entityType.getJavaType().getName() + "'"); + } + } + + @Override + public SelectObjectBuilder> selectNew(Class clazz) { + clearCache(); + if (clazz == null) { + throw new NullPointerException("clazz"); + } + + verifyBuilderEnded(); + return selectManager.selectNew(this, clazz); + } + + @Override + public SelectObjectBuilder> selectNew(Constructor constructor) { + clearCache(); + if (constructor == null) { + throw new NullPointerException("constructor"); + } + + verifyBuilderEnded(); + return selectManager.selectNew(this, constructor); + } + + @Override + @SuppressWarnings("unchecked") + public FullQueryBuilder selectNew(ObjectBuilder objectBuilder) { + clearCache(); + if (objectBuilder == null) { + throw new NullPointerException("objectBuilder"); + } + + verifyBuilderEnded(); + selectManager.selectNew((X) this, objectBuilder); + return (FullQueryBuilder) this; + } + + private void checkFetchJoinAllowed() { + if (selectManager.getSelectInfos().size() > 0) { + throw new IllegalStateException("Fetch joins are only possible if the root entity is selected"); + } + } + + @Override + @SuppressWarnings("unchecked") + public X fetch(String path) { + clearCache(); + checkFetchJoinAllowed(); + verifyBuilderEnded(); + joinManager.implicitJoin(expressionFactory.createSimpleExpression(path), true, null, false, false, true, true); + return (X) this; + } + + @Override + @SuppressWarnings("unchecked") + public X fetch(String... paths) { + clearCache(); + checkFetchJoinAllowed(); + verifyBuilderEnded(); + + for (String path : paths) { + joinManager.implicitJoin(expressionFactory.createSimpleExpression(path), true, null, false, false, true, true); + } + + return (X) this; + } + + @Override + public X innerJoinFetch(String path, String alias) { + return join(path, alias, JoinType.INNER, true); + } + + @Override + public X innerJoinFetchDefault(String path, String alias) { + return joinDefault(path, alias, JoinType.INNER, true); + } + + @Override + public X leftJoinFetch(String path, String alias) { + return join(path, alias, JoinType.LEFT, true); + } + + @Override + public X leftJoinFetchDefault(String path, String alias) { + return joinDefault(path, alias, JoinType.LEFT, true); + } + + @Override + public X rightJoinFetch(String path, String alias) { + return join(path, alias, JoinType.RIGHT, true); + } + + @Override + public X rightJoinFetchDefault(String path, String alias) { + return joinDefault(path, alias, JoinType.RIGHT, true); + } + + @Override + public X join(String path, String alias, JoinType type, boolean fetch) { + return join(path, alias, type, fetch, false); + } + + @Override + public X joinDefault(String path, String alias, JoinType type, boolean fetch) { + return join(path, alias, type, fetch, true); + } + + @SuppressWarnings("unchecked") + private X join(String path, String alias, JoinType type, boolean fetch, boolean defaultJoin) { + clearCache(); + if (path == null) { + throw new NullPointerException("path"); + } + if (alias == null) { + throw new NullPointerException("alias"); + } + if (type == null) { + throw new NullPointerException("type"); + } + if (alias.isEmpty()) { + throw new IllegalArgumentException("Empty alias"); + } + + if (fetch == true) { + checkFetchJoinAllowed(); + } + + verifyBuilderEnded(); + joinManager.join(path, alias, type, fetch, defaultJoin); + return (X) this; + } + + @Override + public X groupBy(String expression) { + if (createdPaginatedBuilder) { + throw new IllegalStateException("Calling groupBy() on a PaginatedCriteriaBuilder is not allowed."); + } + return super.groupBy(expression); + } + + @Override + public X groupBy(String... paths) { + if (createdPaginatedBuilder) { + throw new IllegalStateException("Calling groupBy() on a PaginatedCriteriaBuilder is not allowed."); + } + return super.groupBy(paths); + } + + @Override + public X distinct() { + if (createdPaginatedBuilder) { + throw new IllegalStateException("Calling distinct() on a PaginatedCriteriaBuilder is not allowed."); + } + return super.distinct(); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractQueryBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractQueryBuilder.java index 7226bbc8f5..edc13071b7 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractQueryBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractQueryBuilder.java @@ -1,64 +1,64 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.List; - -import javax.persistence.TypedQuery; - -import com.blazebit.persistence.FullQueryBuilder; -import com.blazebit.persistence.Queryable; -import com.blazebit.persistence.spi.DbmsStatementType; - -/** - * - * @param The query result type - * @param The concrete builder type - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public abstract class AbstractQueryBuilder, Z, W, FinalSetReturn extends BaseFinalSetOperationBuilderImpl> extends AbstractCommonQueryBuilder implements Queryable { - - /** - * Create flat copy of builder - * - * @param builder - */ - protected AbstractQueryBuilder(AbstractQueryBuilder, ?, ?, ?> builder) { - super(builder); - } - - public AbstractQueryBuilder(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias, FinalSetReturn finalSetOperationBuilder) { - super(mainQuery, isMainQuery, DbmsStatementType.SELECT, clazz, alias, finalSetOperationBuilder); - } - - @Override - public TypedQuery getQuery() { - return getTypedQuery(); - } - - @Override - public List getResultList() { - return getQuery().getResultList(); - } - - @Override - public T getSingleResult() { - return getQuery().getSingleResult(); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.List; + +import javax.persistence.TypedQuery; + +import com.blazebit.persistence.FullQueryBuilder; +import com.blazebit.persistence.Queryable; +import com.blazebit.persistence.spi.DbmsStatementType; + +/** + * + * @param The query result type + * @param The concrete builder type + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public abstract class AbstractQueryBuilder, Z, W, FinalSetReturn extends BaseFinalSetOperationBuilderImpl> extends AbstractCommonQueryBuilder implements Queryable { + + /** + * Create flat copy of builder + * + * @param builder + */ + protected AbstractQueryBuilder(AbstractQueryBuilder, ?, ?, ?> builder) { + super(builder); + } + + public AbstractQueryBuilder(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias, FinalSetReturn finalSetOperationBuilder) { + super(mainQuery, isMainQuery, DbmsStatementType.SELECT, clazz, alias, finalSetOperationBuilder); + } + + @Override + public TypedQuery getQuery() { + return getTypedQuery(); + } + + @Override + public List getResultList() { + return getQuery().getResultList(); + } + + @Override + public T getSingleResult() { + return getQuery().getSingleResult(); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AggregateDetectionVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AggregateDetectionVisitor.java index 93a9b72146..b61b754a09 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AggregateDetectionVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AggregateDetectionVisitor.java @@ -1,16 +1,16 @@ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.AbortableVisitorAdapter; -import com.blazebit.persistence.impl.expression.AggregateExpression; -import com.blazebit.persistence.impl.expression.FunctionExpression; - -class AggregateDetectionVisitor extends AbortableVisitorAdapter { - - @Override - public Boolean visit(FunctionExpression expression) { - if (expression instanceof AggregateExpression) { - return true; - } - return super.visit(expression); - } +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.AbortableVisitorAdapter; +import com.blazebit.persistence.impl.expression.AggregateExpression; +import com.blazebit.persistence.impl.expression.FunctionExpression; + +class AggregateDetectionVisitor extends AbortableVisitorAdapter { + + @Override + public Boolean visit(FunctionExpression expression) { + if (expression instanceof AggregateExpression) { + return true; + } + return super.visit(expression); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AliasInfo.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AliasInfo.java index 87f5ca9827..2e3c793c9b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AliasInfo.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AliasInfo.java @@ -1,28 +1,28 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public interface AliasInfo { - - public String getAlias(); - - public AliasManager getAliasOwner(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public interface AliasInfo { + + public String getAlias(); + + public AliasManager getAliasOwner(); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AliasManager.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AliasManager.java index 477b681ff0..dddc26a0cf 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AliasManager.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AliasManager.java @@ -1,128 +1,128 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class AliasManager { - - private final AliasManager parent; - private final Map aliasMap = new HashMap(); // maps alias to absolute path and join manager of - // the declaring query - private final Map aliasCounterMap = new HashMap(); // maps non postfixed aliases to alias counter - - public AliasManager() { - this.parent = null; - } - - public AliasManager(AliasManager parent) { - this.parent = parent; - } - - public AliasInfo getAliasInfo(String alias) { - return getHierarchical(alias); - } - - public AliasInfo getAliasInfoForBottomLevel(String alias) { - return aliasMap.get(alias); - } - - /** - * Register the given alias info if possible - * If the given alias already exists an exception is thrown. - * - * @param aliasInfo - * @return The registered alias - */ - public String registerAliasInfo(AliasInfo aliasInfo) { - String alias = aliasInfo.getAlias(); - if (getHierarchical(alias) != null) { - throw new IllegalArgumentException("Alias '" + alias + "' already exsits"); - } - aliasMap.put(alias, aliasInfo); - aliasCounterMap.put(alias, 0); - return alias; - } - - public String generatePostfixedAlias(String alias) { - Integer counter; - String nonPostfixed = alias; - if ((counter = getCounterHierarchical(alias)) != null) { - // non postfixed version of the alias already exists - counter++; - } else { - // alias does not exist so just register it - counter = 1; - } - alias = alias + "_" + counter; - aliasCounterMap.put(nonPostfixed, counter); - return alias; - } - - private AliasInfo getHierarchical(String alias) { - AliasInfo info = null; - if (parent != null) { - info = parent.getHierarchical(alias); - } - if (info == null) { - info = aliasMap.get(alias); - } - return info; - } - - private Integer getCounterHierarchical(String alias) { - Integer counter = null; - if (parent != null) { - counter = parent.getCounterHierarchical(alias); - } - if (counter == null) { - counter = aliasCounterMap.get(alias); - } - return counter; - } - - public void unregisterAliasInfoForBottomLevel(AliasInfo aliasInfo) { - String alias = aliasInfo.getAlias(); - aliasMap.remove(alias); - int counter = aliasCounterMap.get(alias).intValue(); - - if (alias.endsWith("_" + counter)) { - if (counter == 1) { - aliasCounterMap.remove(alias); - } else { - aliasCounterMap.put(alias, counter - 1); - } - } - } - - public Map getAliasMapForBottomLevel() { - return aliasMap; - } - - public boolean isSelectAlias(String alias) { - AliasInfo info; - if ((info = aliasMap.get(alias)) != null) { - return info instanceof SelectInfo; - } - return false; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class AliasManager { + + private final AliasManager parent; + private final Map aliasMap = new HashMap(); // maps alias to absolute path and join manager of + // the declaring query + private final Map aliasCounterMap = new HashMap(); // maps non postfixed aliases to alias counter + + public AliasManager() { + this.parent = null; + } + + public AliasManager(AliasManager parent) { + this.parent = parent; + } + + public AliasInfo getAliasInfo(String alias) { + return getHierarchical(alias); + } + + public AliasInfo getAliasInfoForBottomLevel(String alias) { + return aliasMap.get(alias); + } + + /** + * Register the given alias info if possible + * If the given alias already exists an exception is thrown. + * + * @param aliasInfo + * @return The registered alias + */ + public String registerAliasInfo(AliasInfo aliasInfo) { + String alias = aliasInfo.getAlias(); + if (getHierarchical(alias) != null) { + throw new IllegalArgumentException("Alias '" + alias + "' already exsits"); + } + aliasMap.put(alias, aliasInfo); + aliasCounterMap.put(alias, 0); + return alias; + } + + public String generatePostfixedAlias(String alias) { + Integer counter; + String nonPostfixed = alias; + if ((counter = getCounterHierarchical(alias)) != null) { + // non postfixed version of the alias already exists + counter++; + } else { + // alias does not exist so just register it + counter = 1; + } + alias = alias + "_" + counter; + aliasCounterMap.put(nonPostfixed, counter); + return alias; + } + + private AliasInfo getHierarchical(String alias) { + AliasInfo info = null; + if (parent != null) { + info = parent.getHierarchical(alias); + } + if (info == null) { + info = aliasMap.get(alias); + } + return info; + } + + private Integer getCounterHierarchical(String alias) { + Integer counter = null; + if (parent != null) { + counter = parent.getCounterHierarchical(alias); + } + if (counter == null) { + counter = aliasCounterMap.get(alias); + } + return counter; + } + + public void unregisterAliasInfoForBottomLevel(AliasInfo aliasInfo) { + String alias = aliasInfo.getAlias(); + aliasMap.remove(alias); + int counter = aliasCounterMap.get(alias).intValue(); + + if (alias.endsWith("_" + counter)) { + if (counter == 1) { + aliasCounterMap.remove(alias); + } else { + aliasCounterMap.put(alias, counter - 1); + } + } + } + + public Map getAliasMapForBottomLevel() { + return aliasMap; + } + + public boolean isSelectAlias(String alias) { + AliasInfo info; + if ((info = aliasMap.get(alias)) != null) { + return info instanceof SelectInfo; + } + return false; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseDeleteCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseDeleteCriteriaBuilderImpl.java index 545a1efddf..a979e47d9e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseDeleteCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseDeleteCriteriaBuilderImpl.java @@ -1,41 +1,41 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.BaseDeleteCriteriaBuilder; -import com.blazebit.persistence.spi.DbmsStatementType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class BaseDeleteCriteriaBuilderImpl, Y> extends AbstractModificationCriteriaBuilder implements BaseDeleteCriteriaBuilder { - - public BaseDeleteCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { - super(mainQuery, isMainQuery, DbmsStatementType.DELETE, clazz, alias, cteName, cteClass, result, listener); - } - - @Override - protected void getQueryString1(StringBuilder sbSelectFrom) { - sbSelectFrom.append("DELETE FROM "); - sbSelectFrom.append(entityType.getName()).append(' '); - sbSelectFrom.append(entityAlias); - appendWhereClause(sbSelectFrom); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.BaseDeleteCriteriaBuilder; +import com.blazebit.persistence.spi.DbmsStatementType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class BaseDeleteCriteriaBuilderImpl, Y> extends AbstractModificationCriteriaBuilder implements BaseDeleteCriteriaBuilder { + + public BaseDeleteCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { + super(mainQuery, isMainQuery, DbmsStatementType.DELETE, clazz, alias, cteName, cteClass, result, listener); + } + + @Override + protected void getQueryString1(StringBuilder sbSelectFrom) { + sbSelectFrom.append("DELETE FROM "); + sbSelectFrom.append(entityType.getName()).append(' '); + sbSelectFrom.append(entityAlias); + appendWhereClause(sbSelectFrom); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationCTECriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationCTECriteriaBuilderImpl.java index 5ecf3630ef..4073d63b2c 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationCTECriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationCTECriteriaBuilderImpl.java @@ -1,87 +1,87 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.List; - -import com.blazebit.persistence.BaseFinalSetOperationBuilder; -import com.blazebit.persistence.BaseOngoingFinalSetOperationBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class BaseFinalSetOperationCTECriteriaBuilderImpl> extends BaseFinalSetOperationBuilderImpl> implements BaseOngoingFinalSetOperationBuilder, CTEInfoBuilder { - - protected final T result; - protected final CTEBuilderListener listener; - protected final FullSelectCTECriteriaBuilderImpl initiator; - protected final CTEBuilderListenerImpl subListener; - - public BaseFinalSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, Class clazz, T result, SetOperationType operator, boolean nested, CTEBuilderListener listener, FullSelectCTECriteriaBuilderImpl initiator) { - super(mainQuery, false, clazz, operator, nested, result); - this.result = result; - this.listener = listener; - this.initiator = initiator; - this.subListener = new CTEBuilderListenerImpl(); - } - - public FullSelectCTECriteriaBuilderImpl getInitiator() { - return initiator; - } - - public T getResult() { - return result; - } - - public CTEBuilderListener getListener() { - return listener; - } - - public CTEBuilderListenerImpl getSubListener() { - return subListener; - } - - @Override - public CTEInfo createCTEInfo() { - return createCTEInfo(this, this); - } - - private static CTEInfo createCTEInfo(AbstractCommonQueryBuilder queryBuilder, AbstractCommonQueryBuilder target) { - if (queryBuilder instanceof BaseFinalSetOperationCTECriteriaBuilderImpl) { - BaseFinalSetOperationCTECriteriaBuilderImpl setOperationBuilder = (BaseFinalSetOperationCTECriteriaBuilderImpl) queryBuilder; - - if (setOperationBuilder.initiator == null) { - return createCTEInfo(setOperationBuilder.setOperationManager.getStartQueryBuilder(), target); - } else { - List attributes = setOperationBuilder.initiator.prepareAndGetAttributes(); - CTEInfo info = new CTEInfo(setOperationBuilder.initiator.cteName, setOperationBuilder.initiator.cteType, attributes, false, false, target, null); - return info; - } - } else if (queryBuilder instanceof AbstractCTECriteriaBuilder) { - AbstractCTECriteriaBuilder cteBuilder = (AbstractCTECriteriaBuilder) queryBuilder; - List attributes = cteBuilder.prepareAndGetAttributes(); - CTEInfo info = new CTEInfo(cteBuilder.cteName, cteBuilder.cteType, attributes, false, false, target, null); - return info; - } - - throw new IllegalArgumentException("Unsupported query builder type for creating a CTE info: " + queryBuilder); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.List; + +import com.blazebit.persistence.BaseFinalSetOperationBuilder; +import com.blazebit.persistence.BaseOngoingFinalSetOperationBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class BaseFinalSetOperationCTECriteriaBuilderImpl> extends BaseFinalSetOperationBuilderImpl> implements BaseOngoingFinalSetOperationBuilder, CTEInfoBuilder { + + protected final T result; + protected final CTEBuilderListener listener; + protected final FullSelectCTECriteriaBuilderImpl initiator; + protected final CTEBuilderListenerImpl subListener; + + public BaseFinalSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, Class clazz, T result, SetOperationType operator, boolean nested, CTEBuilderListener listener, FullSelectCTECriteriaBuilderImpl initiator) { + super(mainQuery, false, clazz, operator, nested, result); + this.result = result; + this.listener = listener; + this.initiator = initiator; + this.subListener = new CTEBuilderListenerImpl(); + } + + public FullSelectCTECriteriaBuilderImpl getInitiator() { + return initiator; + } + + public T getResult() { + return result; + } + + public CTEBuilderListener getListener() { + return listener; + } + + public CTEBuilderListenerImpl getSubListener() { + return subListener; + } + + @Override + public CTEInfo createCTEInfo() { + return createCTEInfo(this, this); + } + + private static CTEInfo createCTEInfo(AbstractCommonQueryBuilder queryBuilder, AbstractCommonQueryBuilder target) { + if (queryBuilder instanceof BaseFinalSetOperationCTECriteriaBuilderImpl) { + BaseFinalSetOperationCTECriteriaBuilderImpl setOperationBuilder = (BaseFinalSetOperationCTECriteriaBuilderImpl) queryBuilder; + + if (setOperationBuilder.initiator == null) { + return createCTEInfo(setOperationBuilder.setOperationManager.getStartQueryBuilder(), target); + } else { + List attributes = setOperationBuilder.initiator.prepareAndGetAttributes(); + CTEInfo info = new CTEInfo(setOperationBuilder.initiator.cteName, setOperationBuilder.initiator.cteType, attributes, false, false, target, null); + return info; + } + } else if (queryBuilder instanceof AbstractCTECriteriaBuilder) { + AbstractCTECriteriaBuilder cteBuilder = (AbstractCTECriteriaBuilder) queryBuilder; + List attributes = cteBuilder.prepareAndGetAttributes(); + CTEInfo info = new CTEInfo(cteBuilder.cteName, cteBuilder.cteType, attributes, false, false, target, null); + return info; + } + + throw new IllegalArgumentException("Unsupported query builder type for creating a CTE info: " + queryBuilder); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationCriteriaBuilderImpl.java index 0b64a403f0..af218f9156 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationCriteriaBuilderImpl.java @@ -1,56 +1,56 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.BaseFinalSetOperationBuilder; -import com.blazebit.persistence.BaseOngoingFinalSetOperationBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class BaseFinalSetOperationCriteriaBuilderImpl> extends BaseFinalSetOperationBuilderImpl> implements BaseOngoingFinalSetOperationBuilder { - - private final BuilderListener listener; - private final BuilderListenerImpl subListener; - - public BaseFinalSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, SetOperationType operator, boolean nested, BuilderListener listener, T endSetResult) { - super(mainQuery, isMainQuery, clazz, operator, nested, endSetResult); - this.listener = listener; - this.subListener = new BuilderListenerImpl(); - } - - public BuilderListener getListener() { - return listener; - } - - public BuilderListenerImpl getSubListener() { - return subListener; - } - - @Override - protected void prepareAndCheck() { - if (isMainQuery) { - subListener.verifyBuilderEnded(); - } - - super.prepareAndCheck(); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.BaseFinalSetOperationBuilder; +import com.blazebit.persistence.BaseOngoingFinalSetOperationBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class BaseFinalSetOperationCriteriaBuilderImpl> extends BaseFinalSetOperationBuilderImpl> implements BaseOngoingFinalSetOperationBuilder { + + private final BuilderListener listener; + private final BuilderListenerImpl subListener; + + public BaseFinalSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, SetOperationType operator, boolean nested, BuilderListener listener, T endSetResult) { + super(mainQuery, isMainQuery, clazz, operator, nested, endSetResult); + this.listener = listener; + this.subListener = new BuilderListenerImpl(); + } + + public BuilderListener getListener() { + return listener; + } + + public BuilderListenerImpl getSubListener() { + return subListener; + } + + @Override + protected void prepareAndCheck() { + if (isMainQuery) { + subListener.verifyBuilderEnded(); + } + + super.prepareAndCheck(); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationSubqueryBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationSubqueryBuilderImpl.java index 0fe16fbe10..ad17bce604 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationSubqueryBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationSubqueryBuilderImpl.java @@ -1,89 +1,89 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.List; - -import javax.persistence.Tuple; - -import com.blazebit.persistence.BaseFinalSetOperationBuilder; -import com.blazebit.persistence.BaseOngoingFinalSetOperationBuilder; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class BaseFinalSetOperationSubqueryBuilderImpl> extends BaseFinalSetOperationBuilderImpl> implements BaseOngoingFinalSetOperationBuilder, SubqueryInternalBuilder { - - protected final T result; - protected final SubqueryBuilderListener listener; - protected final SubqueryBuilderImpl initiator; - - protected final SubqueryBuilderListenerImpl subListener; - - @SuppressWarnings("unchecked") - public BaseFinalSetOperationSubqueryBuilderImpl(MainQuery mainQuery, T result, SetOperationType operator, boolean nested, SubqueryBuilderListener listener, SubqueryBuilderImpl initiator) { - super(mainQuery, false, (Class) Tuple.class, operator, nested, result); - this.result = result; - this.listener = listener; - this.initiator = initiator; - this.subListener = new SubqueryBuilderListenerImpl(); - } - - public SubqueryBuilderListener getListener() { - return listener; - } - - public SubqueryBuilderListener getSubListener() { - return subListener; - } - - public SubqueryBuilderImpl getInitiator() { - return initiator; - } - - @Override - public T getResult() { - return result; - } - - @Override - public List getSelectExpressions() { - return getSelectExpressions(this); - } - - private static List getSelectExpressions(AbstractCommonQueryBuilder queryBuilder) { - if (queryBuilder instanceof BaseFinalSetOperationSubqueryBuilderImpl) { - BaseFinalSetOperationSubqueryBuilderImpl setOperationBuilder = (BaseFinalSetOperationSubqueryBuilderImpl) queryBuilder; - - if (setOperationBuilder.initiator == null) { - return getSelectExpressions(setOperationBuilder.setOperationManager.getStartQueryBuilder()); - } else { - return setOperationBuilder.initiator.getSelectExpressions(); - } - } else if (queryBuilder instanceof BaseSubqueryBuilderImpl) { - BaseSubqueryBuilderImpl subqueryBuilder = (BaseSubqueryBuilderImpl) queryBuilder; - return subqueryBuilder.getSelectExpressions(); - } - - throw new IllegalArgumentException("Unsupported query builder type for creating select expressions: " + queryBuilder); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.List; + +import javax.persistence.Tuple; + +import com.blazebit.persistence.BaseFinalSetOperationBuilder; +import com.blazebit.persistence.BaseOngoingFinalSetOperationBuilder; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class BaseFinalSetOperationSubqueryBuilderImpl> extends BaseFinalSetOperationBuilderImpl> implements BaseOngoingFinalSetOperationBuilder, SubqueryInternalBuilder { + + protected final T result; + protected final SubqueryBuilderListener listener; + protected final SubqueryBuilderImpl initiator; + + protected final SubqueryBuilderListenerImpl subListener; + + @SuppressWarnings("unchecked") + public BaseFinalSetOperationSubqueryBuilderImpl(MainQuery mainQuery, T result, SetOperationType operator, boolean nested, SubqueryBuilderListener listener, SubqueryBuilderImpl initiator) { + super(mainQuery, false, (Class) Tuple.class, operator, nested, result); + this.result = result; + this.listener = listener; + this.initiator = initiator; + this.subListener = new SubqueryBuilderListenerImpl(); + } + + public SubqueryBuilderListener getListener() { + return listener; + } + + public SubqueryBuilderListener getSubListener() { + return subListener; + } + + public SubqueryBuilderImpl getInitiator() { + return initiator; + } + + @Override + public T getResult() { + return result; + } + + @Override + public List getSelectExpressions() { + return getSelectExpressions(this); + } + + private static List getSelectExpressions(AbstractCommonQueryBuilder queryBuilder) { + if (queryBuilder instanceof BaseFinalSetOperationSubqueryBuilderImpl) { + BaseFinalSetOperationSubqueryBuilderImpl setOperationBuilder = (BaseFinalSetOperationSubqueryBuilderImpl) queryBuilder; + + if (setOperationBuilder.initiator == null) { + return getSelectExpressions(setOperationBuilder.setOperationManager.getStartQueryBuilder()); + } else { + return setOperationBuilder.initiator.getSelectExpressions(); + } + } else if (queryBuilder instanceof BaseSubqueryBuilderImpl) { + BaseSubqueryBuilderImpl subqueryBuilder = (BaseSubqueryBuilderImpl) queryBuilder; + return subqueryBuilder.getSelectExpressions(); + } + + throw new IllegalArgumentException("Unsupported query builder type for creating select expressions: " + queryBuilder); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseInsertCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseInsertCriteriaBuilderImpl.java index 915b60b84e..42cd8a80c4 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseInsertCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseInsertCriteriaBuilderImpl.java @@ -1,141 +1,141 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import javax.persistence.Query; - -import com.blazebit.persistence.BaseInsertCriteriaBuilder; -import com.blazebit.persistence.SelectBuilder; -import com.blazebit.persistence.spi.DbmsStatementType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class BaseInsertCriteriaBuilderImpl, Y> extends AbstractModificationCriteriaBuilder implements BaseInsertCriteriaBuilder, SelectBuilder { - - private final Map bindingMap = new TreeMap(); - - public BaseInsertCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { - super(mainQuery, isMainQuery, DbmsStatementType.INSERT, clazz, null, cteName, cteClass, result, listener); - - if (!jpaProvider.supportsInsertStatement()) { - throw new IllegalStateException("JPA provider does not support insert statements!"); - } - } - - @Override - @SuppressWarnings("unchecked") - public X bind(String attributeName, Object value) { - // NOTE: We are not resolving embedded properties, because hibernate does not support them - // Just do that to assert the attribute exists - if (entityType.getAttribute(attributeName) == null) { - // Well, some implementations might not be fully spec compliant.. - throw new IllegalArgumentException("Attribute '" + attributeName + "' does not exist on '" + entityType.getName() + "'!"); - } - Integer attributeBindIndex = bindingMap.get(attributeName); - - if (attributeBindIndex != null) { - throw new IllegalArgumentException("The attribute [" + attributeName + "] has already been bound!"); - } - - bindingMap.put(attributeName, selectManager.getSelectInfos().size()); - selectManager.select(parameterManager.addParameterExpression(value), null); - - return (X) this; - } - - @Override - public SelectBuilder bind(String attributeName) { - // NOTE: We are not resolving embedded properties, because hibernate does not support them - // Just do that to assert the attribute exists - if (entityType.getAttribute(attributeName) == null) { - // Well, some implementations might not be fully spec compliant.. - throw new IllegalArgumentException("Attribute '" + attributeName + "' does not exist on '" + entityType.getName() + "'!"); - } - Integer attributeBindIndex = bindingMap.get(attributeName); - - if (attributeBindIndex != null) { - throw new IllegalArgumentException("The attribute [" + attributeName + "] has already been bound!"); - } - - bindingMap.put(attributeName, selectManager.getSelectInfos().size()); - return this; - } - - @Override - protected void prepareAndCheck() { - List attributes = new ArrayList(bindingMap.size()); - List originalSelectInfos = new ArrayList(selectManager.getSelectInfos()); - List newSelectInfos = selectManager.getSelectInfos(); - newSelectInfos.clear(); - - for (Map.Entry attributeEntry : bindingMap.entrySet()) { - // Reorder select infos to fit the attribute order - Integer newPosition = attributes.size(); - attributes.add(attributeEntry.getKey()); - - SelectInfo selectInfo = originalSelectInfos.get(attributeEntry.getValue()); - newSelectInfos.add(selectInfo); - attributeEntry.setValue(newPosition); - } - super.prepareAndCheck(); - } - - @Override - protected boolean isJoinRequiredForSelect() { - // NOTE: since we aren't actually selecting properties but passing them through to the insert, we don't require joins - return false; - } - - @Override - protected void getQueryString1(StringBuilder sbSelectFrom) { - sbSelectFrom.append("INSERT INTO "); - sbSelectFrom.append(entityType.getName()).append('('); - - boolean first = true; - for (Map.Entry attributeEntry : bindingMap.entrySet()) { - if (first) { - first = false; - } else { - sbSelectFrom.append(", "); - } - - sbSelectFrom.append(attributeEntry.getKey()); - } - - sbSelectFrom.append(")\n"); - super.getQueryString1(sbSelectFrom); - } - - @Override - public Query getQuery() { - if (jpaProvider.supportsInsertStatement()) { - return super.getQuery(); - } else { - // TODO: implement - throw new UnsupportedOperationException("Not yet implemented!"); - } - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import javax.persistence.Query; + +import com.blazebit.persistence.BaseInsertCriteriaBuilder; +import com.blazebit.persistence.SelectBuilder; +import com.blazebit.persistence.spi.DbmsStatementType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class BaseInsertCriteriaBuilderImpl, Y> extends AbstractModificationCriteriaBuilder implements BaseInsertCriteriaBuilder, SelectBuilder { + + private final Map bindingMap = new TreeMap(); + + public BaseInsertCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { + super(mainQuery, isMainQuery, DbmsStatementType.INSERT, clazz, null, cteName, cteClass, result, listener); + + if (!jpaProvider.supportsInsertStatement()) { + throw new IllegalStateException("JPA provider does not support insert statements!"); + } + } + + @Override + @SuppressWarnings("unchecked") + public X bind(String attributeName, Object value) { + // NOTE: We are not resolving embedded properties, because hibernate does not support them + // Just do that to assert the attribute exists + if (entityType.getAttribute(attributeName) == null) { + // Well, some implementations might not be fully spec compliant.. + throw new IllegalArgumentException("Attribute '" + attributeName + "' does not exist on '" + entityType.getName() + "'!"); + } + Integer attributeBindIndex = bindingMap.get(attributeName); + + if (attributeBindIndex != null) { + throw new IllegalArgumentException("The attribute [" + attributeName + "] has already been bound!"); + } + + bindingMap.put(attributeName, selectManager.getSelectInfos().size()); + selectManager.select(parameterManager.addParameterExpression(value), null); + + return (X) this; + } + + @Override + public SelectBuilder bind(String attributeName) { + // NOTE: We are not resolving embedded properties, because hibernate does not support them + // Just do that to assert the attribute exists + if (entityType.getAttribute(attributeName) == null) { + // Well, some implementations might not be fully spec compliant.. + throw new IllegalArgumentException("Attribute '" + attributeName + "' does not exist on '" + entityType.getName() + "'!"); + } + Integer attributeBindIndex = bindingMap.get(attributeName); + + if (attributeBindIndex != null) { + throw new IllegalArgumentException("The attribute [" + attributeName + "] has already been bound!"); + } + + bindingMap.put(attributeName, selectManager.getSelectInfos().size()); + return this; + } + + @Override + protected void prepareAndCheck() { + List attributes = new ArrayList(bindingMap.size()); + List originalSelectInfos = new ArrayList(selectManager.getSelectInfos()); + List newSelectInfos = selectManager.getSelectInfos(); + newSelectInfos.clear(); + + for (Map.Entry attributeEntry : bindingMap.entrySet()) { + // Reorder select infos to fit the attribute order + Integer newPosition = attributes.size(); + attributes.add(attributeEntry.getKey()); + + SelectInfo selectInfo = originalSelectInfos.get(attributeEntry.getValue()); + newSelectInfos.add(selectInfo); + attributeEntry.setValue(newPosition); + } + super.prepareAndCheck(); + } + + @Override + protected boolean isJoinRequiredForSelect() { + // NOTE: since we aren't actually selecting properties but passing them through to the insert, we don't require joins + return false; + } + + @Override + protected void getQueryString1(StringBuilder sbSelectFrom) { + sbSelectFrom.append("INSERT INTO "); + sbSelectFrom.append(entityType.getName()).append('('); + + boolean first = true; + for (Map.Entry attributeEntry : bindingMap.entrySet()) { + if (first) { + first = false; + } else { + sbSelectFrom.append(", "); + } + + sbSelectFrom.append(attributeEntry.getKey()); + } + + sbSelectFrom.append(")\n"); + super.getQueryString1(sbSelectFrom); + } + + @Override + public Query getQuery() { + if (jpaProvider.supportsInsertStatement()) { + return super.getQuery(); + } else { + // TODO: implement + throw new UnsupportedOperationException("Not yet implemented!"); + } + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseSubqueryBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseSubqueryBuilderImpl.java index ff4230b54d..e39c6e0e0e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseSubqueryBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseSubqueryBuilderImpl.java @@ -1,102 +1,102 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.ArrayList; -import java.util.List; - -import javax.persistence.Tuple; - -import com.blazebit.persistence.BaseOngoingSetOperationBuilder; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.spi.DbmsStatementType; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class BaseSubqueryBuilderImpl, Z extends BaseOngoingSetOperationBuilder> extends AbstractCommonQueryBuilder> implements SubqueryInternalBuilder { - - protected final T result; - protected final SubqueryBuilderListener listener; - protected final SubqueryBuilderListenerImpl subListener; - - public BaseSubqueryBuilderImpl(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager, ExpressionFactory expressionFactory, T result, SubqueryBuilderListener listener, BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { - super(mainQuery, false, DbmsStatementType.SELECT, Tuple.class, null, aliasManager, parentJoinManager, expressionFactory, finalSetOperationBuilder); - this.result = result; - this.listener = listener; - this.subListener = new SubqueryBuilderListenerImpl(); - } - - public SubqueryBuilderListenerImpl getSubListener() { - return subListener; - } - - @Override - public List getSelectExpressions() { - List selectExpressions = new ArrayList(selectManager.getSelectInfos().size()); - - for (SelectInfo info : selectManager.getSelectInfos()) { - selectExpressions.add(info.getExpression()); - } - - return selectExpressions; - } - - public T getResult() { - return result; - } - - protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested, boolean isSubquery) { - SubqueryBuilderImpl newInitiator = finalSetOperationBuilder == null ? null : finalSetOperationBuilder.getInitiator(); - return createFinalSetOperationBuilder(operator, nested, isSubquery, newInitiator); - } - - protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested, boolean isSubquery, SubqueryBuilderImpl newInitiator) { - // TODO: this should never be null, handle it! - SubqueryBuilderListener newListener = finalSetOperationBuilder == null ? listener : finalSetOperationBuilder.getSubListener(); - T newResult = finalSetOperationBuilder == null ? result : finalSetOperationBuilder.getResult(); - - if (isSubquery) { - return new OngoingFinalSetOperationSubqueryBuilderImpl(mainQuery, newResult, operator, nested, newListener, newInitiator); - } else { - return new FinalSetOperationSubqueryBuilderImpl(mainQuery, newResult, operator, nested, newListener, newInitiator); - } - } - - @SuppressWarnings("unchecked") - protected LeafOngoingSetOperationSubqueryBuilderImpl createLeaf(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { - SubqueryBuilderListener newListener = finalSetOperationBuilder.getSubListener(); - LeafOngoingSetOperationSubqueryBuilderImpl next = new LeafOngoingSetOperationSubqueryBuilderImpl(mainQuery, aliasManager, joinManager.getParent(), expressionFactory, result, newListener, (FinalSetOperationSubqueryBuilderImpl) finalSetOperationBuilder); - newListener.onBuilderStarted(next); - return next; - } - - @SuppressWarnings("unchecked") - protected OngoingSetOperationSubqueryBuilderImpl createOngoing(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, W endSetResult) { - // TODO: This is such an ugly hack, but I don't know how else to fix this generics issue for now - finalSetOperationBuilder.setEndSetResult((T) endSetResult); - - SubqueryBuilderListener newListener = finalSetOperationBuilder.getSubListener(); - OngoingSetOperationSubqueryBuilderImpl next = new OngoingSetOperationSubqueryBuilderImpl(mainQuery, aliasManager, joinManager.getParent(), expressionFactory, result, newListener, (OngoingFinalSetOperationSubqueryBuilderImpl) finalSetOperationBuilder, endSetResult); - newListener.onBuilderStarted(next); - return next; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Tuple; + +import com.blazebit.persistence.BaseOngoingSetOperationBuilder; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.spi.DbmsStatementType; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class BaseSubqueryBuilderImpl, Z extends BaseOngoingSetOperationBuilder> extends AbstractCommonQueryBuilder> implements SubqueryInternalBuilder { + + protected final T result; + protected final SubqueryBuilderListener listener; + protected final SubqueryBuilderListenerImpl subListener; + + public BaseSubqueryBuilderImpl(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager, ExpressionFactory expressionFactory, T result, SubqueryBuilderListener listener, BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { + super(mainQuery, false, DbmsStatementType.SELECT, Tuple.class, null, aliasManager, parentJoinManager, expressionFactory, finalSetOperationBuilder); + this.result = result; + this.listener = listener; + this.subListener = new SubqueryBuilderListenerImpl(); + } + + public SubqueryBuilderListenerImpl getSubListener() { + return subListener; + } + + @Override + public List getSelectExpressions() { + List selectExpressions = new ArrayList(selectManager.getSelectInfos().size()); + + for (SelectInfo info : selectManager.getSelectInfos()) { + selectExpressions.add(info.getExpression()); + } + + return selectExpressions; + } + + public T getResult() { + return result; + } + + protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested, boolean isSubquery) { + SubqueryBuilderImpl newInitiator = finalSetOperationBuilder == null ? null : finalSetOperationBuilder.getInitiator(); + return createFinalSetOperationBuilder(operator, nested, isSubquery, newInitiator); + } + + protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested, boolean isSubquery, SubqueryBuilderImpl newInitiator) { + // TODO: this should never be null, handle it! + SubqueryBuilderListener newListener = finalSetOperationBuilder == null ? listener : finalSetOperationBuilder.getSubListener(); + T newResult = finalSetOperationBuilder == null ? result : finalSetOperationBuilder.getResult(); + + if (isSubquery) { + return new OngoingFinalSetOperationSubqueryBuilderImpl(mainQuery, newResult, operator, nested, newListener, newInitiator); + } else { + return new FinalSetOperationSubqueryBuilderImpl(mainQuery, newResult, operator, nested, newListener, newInitiator); + } + } + + @SuppressWarnings("unchecked") + protected LeafOngoingSetOperationSubqueryBuilderImpl createLeaf(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { + SubqueryBuilderListener newListener = finalSetOperationBuilder.getSubListener(); + LeafOngoingSetOperationSubqueryBuilderImpl next = new LeafOngoingSetOperationSubqueryBuilderImpl(mainQuery, aliasManager, joinManager.getParent(), expressionFactory, result, newListener, (FinalSetOperationSubqueryBuilderImpl) finalSetOperationBuilder); + newListener.onBuilderStarted(next); + return next; + } + + @SuppressWarnings("unchecked") + protected OngoingSetOperationSubqueryBuilderImpl createOngoing(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, W endSetResult) { + // TODO: This is such an ugly hack, but I don't know how else to fix this generics issue for now + finalSetOperationBuilder.setEndSetResult((T) endSetResult); + + SubqueryBuilderListener newListener = finalSetOperationBuilder.getSubListener(); + OngoingSetOperationSubqueryBuilderImpl next = new OngoingSetOperationSubqueryBuilderImpl(mainQuery, aliasManager, joinManager.getParent(), expressionFactory, result, newListener, (OngoingFinalSetOperationSubqueryBuilderImpl) finalSetOperationBuilder, endSetResult); + newListener.onBuilderStarted(next); + return next; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderChainingException.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderChainingException.java index 94d7eb0d84..245c9d148c 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderChainingException.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderChainingException.java @@ -1,44 +1,44 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -/** - * - * @author Moritz Becker - * @since 1.0.5 - */ -public class BuilderChainingException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - /** - * Creates a new instance of BuilderNotEndedException without - * detail message. - */ - public BuilderChainingException() { - } - - /** - * Constructs an instance of BuilderNotEndedException with the - * specified detail message. - * - * @param msg the detail message. - */ - public BuilderChainingException(String msg) { - super(msg); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +/** + * + * @author Moritz Becker + * @since 1.0.5 + */ +public class BuilderChainingException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance of BuilderNotEndedException without + * detail message. + */ + public BuilderChainingException() { + } + + /** + * Constructs an instance of BuilderNotEndedException with the + * specified detail message. + * + * @param msg the detail message. + */ + public BuilderChainingException(String msg) { + super(msg); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderListener.java index 07290d4da1..2930d70ae2 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderListener.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - - -/** - * - * @author Christian Beikov - * @since 1.1.0 - */ -public interface BuilderListener { - - public void onReplaceBuilder(T oldBuilder, T newBuilder); - - public void onBuilderEnded(T builder); - - public void onBuilderStarted(T builder); - - public boolean isBuilderEnded(); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + + +/** + * + * @author Christian Beikov + * @since 1.1.0 + */ +public interface BuilderListener { + + public void onReplaceBuilder(T oldBuilder, T newBuilder); + + public void onBuilderEnded(T builder); + + public void onBuilderStarted(T builder); + + public boolean isBuilderEnded(); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderListenerImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderListenerImpl.java index 516336933f..1543357cd6 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderListenerImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BuilderListenerImpl.java @@ -1,66 +1,66 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - - -/** - * - * @author Christian Beikov - * @since 1.1.0 - */ -public class BuilderListenerImpl implements BuilderListener { - - private T currentBuilder; - - public void onReplaceBuilder(T oldBuilder, T newBuilder) { - if (currentBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - if (currentBuilder != oldBuilder) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - - currentBuilder = newBuilder; - } - - public void verifyBuilderEnded() { - if (currentBuilder != null) { - throw new BuilderChainingException("A builder was not ended properly."); - } - } - - @Override - public void onBuilderEnded(T builder) { - if (currentBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - currentBuilder = null; - } - - @Override - public void onBuilderStarted(T builder) { - if (currentBuilder != null) { - throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); - } - - currentBuilder = builder; - } - - @Override - public boolean isBuilderEnded() { - return currentBuilder == null; - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + + +/** + * + * @author Christian Beikov + * @since 1.1.0 + */ +public class BuilderListenerImpl implements BuilderListener { + + private T currentBuilder; + + public void onReplaceBuilder(T oldBuilder, T newBuilder) { + if (currentBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + if (currentBuilder != oldBuilder) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + + currentBuilder = newBuilder; + } + + public void verifyBuilderEnded() { + if (currentBuilder != null) { + throw new BuilderChainingException("A builder was not ended properly."); + } + } + + @Override + public void onBuilderEnded(T builder) { + if (currentBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + currentBuilder = null; + } + + @Override + public void onBuilderStarted(T builder) { + if (currentBuilder != null) { + throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); + } + + currentBuilder = builder; + } + + @Override + public boolean isBuilderEnded() { + return currentBuilder == null; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEBuilderListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEBuilderListener.java index eaa06ec692..7dbdb6e356 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEBuilderListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEBuilderListener.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -/** - * - * @author Christian Beikov - * @since 1.1.0 - */ -public interface CTEBuilderListener { - - public void onReplaceBuilder(CTEInfoBuilder oldBuilder, CTEInfoBuilder newBuilder); - - public void onBuilderEnded(CTEInfoBuilder builder); - - public void onBuilderStarted(CTEInfoBuilder builder); -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +/** + * + * @author Christian Beikov + * @since 1.1.0 + */ +public interface CTEBuilderListener { + + public void onReplaceBuilder(CTEInfoBuilder oldBuilder, CTEInfoBuilder newBuilder); + + public void onBuilderEnded(CTEInfoBuilder builder); + + public void onBuilderStarted(CTEInfoBuilder builder); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEBuilderListenerImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEBuilderListenerImpl.java index f4c7a160b7..4420f8dd1e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEBuilderListenerImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEBuilderListenerImpl.java @@ -1,60 +1,60 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -/** - * - * @author Christian Beikov - * @since 1.1.0 - */ -public class CTEBuilderListenerImpl implements CTEBuilderListener { - - private CTEInfoBuilder currentCteBuilder; - - public void onReplaceBuilder(CTEInfoBuilder oldBuilder, CTEInfoBuilder newBuilder) { - if (currentCteBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - if (currentCteBuilder != oldBuilder) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - - currentCteBuilder = newBuilder; - } - - public void verifyBuilderEnded() { - if (currentCteBuilder != null) { - throw new BuilderChainingException("A builder was not ended properly."); - } - } - - @Override - public void onBuilderEnded(CTEInfoBuilder builder) { - if (currentCteBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - currentCteBuilder = null; - } - - @Override - public void onBuilderStarted(CTEInfoBuilder builder) { - if (currentCteBuilder != null) { - throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); - } - - currentCteBuilder = builder; - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +/** + * + * @author Christian Beikov + * @since 1.1.0 + */ +public class CTEBuilderListenerImpl implements CTEBuilderListener { + + private CTEInfoBuilder currentCteBuilder; + + public void onReplaceBuilder(CTEInfoBuilder oldBuilder, CTEInfoBuilder newBuilder) { + if (currentCteBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + if (currentCteBuilder != oldBuilder) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + + currentCteBuilder = newBuilder; + } + + public void verifyBuilderEnded() { + if (currentCteBuilder != null) { + throw new BuilderChainingException("A builder was not ended properly."); + } + } + + @Override + public void onBuilderEnded(CTEInfoBuilder builder) { + if (currentCteBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + currentCteBuilder = null; + } + + @Override + public void onBuilderStarted(CTEInfoBuilder builder) { + if (currentCteBuilder != null) { + throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); + } + + currentCteBuilder = builder; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEInfo.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEInfo.java index d69c9a3daa..34df24c9ac 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEInfo.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEInfo.java @@ -1,50 +1,50 @@ -package com.blazebit.persistence.impl; - -import java.util.List; - -import javax.persistence.metamodel.EntityType; - -class CTEInfo { - final String name; - final EntityType cteType; - final List attributes; - final boolean recursive; - final boolean unionAll; - final AbstractCommonQueryBuilder nonRecursiveCriteriaBuilder; - final AbstractCommonQueryBuilder recursiveCriteriaBuilder; - - CTEInfo(String name, EntityType cteType, List attributes, boolean recursive, boolean unionAll, AbstractCommonQueryBuilder nonRecursiveCriteriaBuilder, AbstractCommonQueryBuilder recursiveCriteriaBuilder) { - this.name = name; - this.cteType = cteType; - this.attributes = attributes; - this.recursive = recursive; - this.unionAll = unionAll; - this.nonRecursiveCriteriaBuilder = nonRecursiveCriteriaBuilder; - this.recursiveCriteriaBuilder = recursiveCriteriaBuilder; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CTEInfo other = (CTEInfo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } +package com.blazebit.persistence.impl; + +import java.util.List; + +import javax.persistence.metamodel.EntityType; + +class CTEInfo { + final String name; + final EntityType cteType; + final List attributes; + final boolean recursive; + final boolean unionAll; + final AbstractCommonQueryBuilder nonRecursiveCriteriaBuilder; + final AbstractCommonQueryBuilder recursiveCriteriaBuilder; + + CTEInfo(String name, EntityType cteType, List attributes, boolean recursive, boolean unionAll, AbstractCommonQueryBuilder nonRecursiveCriteriaBuilder, AbstractCommonQueryBuilder recursiveCriteriaBuilder) { + this.name = name; + this.cteType = cteType; + this.attributes = attributes; + this.recursive = recursive; + this.unionAll = unionAll; + this.nonRecursiveCriteriaBuilder = nonRecursiveCriteriaBuilder; + this.recursiveCriteriaBuilder = recursiveCriteriaBuilder; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CTEInfo other = (CTEInfo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEInfoBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEInfoBuilder.java index 750fece622..df94f85960 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEInfoBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEInfoBuilder.java @@ -1,27 +1,27 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -/** - * - * @author Christian Beikov - * @since 1.1.0 - */ -public interface CTEInfoBuilder { - - public CTEInfo createCTEInfo(); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +/** + * + * @author Christian Beikov + * @since 1.1.0 + */ +public interface CTEInfoBuilder { + + public CTEInfo createCTEInfo(); + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEManager.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEManager.java index c5eb77d99d..4f78925e16 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/CTEManager.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CTEManager.java @@ -1,152 +1,152 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import com.blazebit.persistence.FullSelectCTECriteriaBuilder; -import com.blazebit.persistence.LeafOngoingSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.ReturningModificationCriteriaBuilderFactory; -import com.blazebit.persistence.SelectRecursiveCTECriteriaBuilder; -import com.blazebit.persistence.StartOngoingSetOperationCTECriteriaBuilder; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.1.0 - */ -public class CTEManager extends CTEBuilderListenerImpl { - - private final MainQuery mainQuery; - private final Set ctes; - private boolean recursive = false; - - CTEManager(MainQuery mainQuery) { - this.mainQuery = mainQuery; - this.ctes = new LinkedHashSet(); - } - - Set getCtes() { - return ctes; - } - - public boolean hasCtes() { - return ctes.size() > 0; - } - - boolean isRecursive() { - return recursive; - } - - void buildClause(StringBuilder sb) { - if (ctes.isEmpty()) { - return; - } - - sb.append("WITH "); - - if (recursive) { - sb.append("RECURSIVE "); - } - - boolean first = true; - for (CTEInfo cte : ctes) { - if (first) { - first = false; - } else { - sb.append(", "); - } - - sb.append(cte.name); - sb.append('('); - - final List attributes = cte.attributes; - sb.append(attributes.get(0)); - - for (int i = 1; i < attributes.size(); i++) { - sb.append(", "); - sb.append(attributes.get(i)); - } - - sb.append(')'); - - sb.append(" AS(\n"); - sb.append(cte.nonRecursiveCriteriaBuilder.getQueryString()); - - if (cte.recursive) { - sb.append("\nUNION ALL\n"); - sb.append(cte.recursiveCriteriaBuilder.getQueryString()); - } - - sb.append("\n)"); - } - - sb.append("\n"); - } - - @SuppressWarnings("unchecked") - StartOngoingSetOperationCTECriteriaBuilder> withStartSet(Class cteClass, Y result) { - String cteName = cteClass.getSimpleName(); - FinalSetOperationCTECriteriaBuilderImpl parentFinalSetOperationBuilder = new FinalSetOperationCTECriteriaBuilderImpl(mainQuery, (Class) cteClass, result, null, false, this, null); - OngoingFinalSetOperationCTECriteriaBuilderImpl subFinalSetOperationBuilder = new OngoingFinalSetOperationCTECriteriaBuilderImpl(mainQuery, (Class) cteClass, null, null, true, parentFinalSetOperationBuilder.getSubListener(), null); - this.onBuilderStarted(parentFinalSetOperationBuilder); - - LeafOngoingSetOperationCTECriteriaBuilderImpl leafCb = new LeafOngoingSetOperationCTECriteriaBuilderImpl(mainQuery, cteName, (Class) cteClass, result, parentFinalSetOperationBuilder.getSubListener(), (FinalSetOperationCTECriteriaBuilderImpl) parentFinalSetOperationBuilder); - OngoingSetOperationCTECriteriaBuilderImpl> cb = new OngoingSetOperationCTECriteriaBuilderImpl>(mainQuery, cteName, (Class) cteClass, result, subFinalSetOperationBuilder.getSubListener(), (OngoingFinalSetOperationCTECriteriaBuilderImpl) subFinalSetOperationBuilder, leafCb); - - subFinalSetOperationBuilder.setOperationManager.setStartQueryBuilder(cb); - parentFinalSetOperationBuilder.setOperationManager.setStartQueryBuilder(subFinalSetOperationBuilder); - - subFinalSetOperationBuilder.getSubListener().onBuilderStarted(cb); - parentFinalSetOperationBuilder.getSubListener().onBuilderStarted(leafCb); - - return cb; - } - - @SuppressWarnings("unchecked") - FullSelectCTECriteriaBuilder with(Class cteClass, Y result) { - String cteName = cteClass.getSimpleName(); - FullSelectCTECriteriaBuilderImpl cteBuilder = new FullSelectCTECriteriaBuilderImpl(mainQuery, cteName, (Class) cteClass, result, this); - this.onBuilderStarted(cteBuilder); - return cteBuilder; - } - - @SuppressWarnings("unchecked") - SelectRecursiveCTECriteriaBuilder withRecursive(Class cteClass, Y result) { - String cteName = cteClass.getSimpleName(); - recursive = true; - RecursiveCTECriteriaBuilderImpl cteBuilder = new RecursiveCTECriteriaBuilderImpl(mainQuery, cteName, (Class) cteClass, result, this); - this.onBuilderStarted(cteBuilder); - return cteBuilder; - } - - ReturningModificationCriteriaBuilderFactory withReturning(Class cteClass, Y result) { - String cteName = cteClass.getSimpleName(); - ReturningModificationCriteraBuilderFactoryImpl factory = new ReturningModificationCriteraBuilderFactoryImpl(mainQuery, cteName, cteClass, result, this); - return factory; - } - - @Override - public void onBuilderEnded(CTEInfoBuilder builder) { - super.onBuilderEnded(builder); - CTEInfo cteInfo = builder.createCTEInfo(); - ctes.add(cteInfo); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import com.blazebit.persistence.FullSelectCTECriteriaBuilder; +import com.blazebit.persistence.LeafOngoingSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.ReturningModificationCriteriaBuilderFactory; +import com.blazebit.persistence.SelectRecursiveCTECriteriaBuilder; +import com.blazebit.persistence.StartOngoingSetOperationCTECriteriaBuilder; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.1.0 + */ +public class CTEManager extends CTEBuilderListenerImpl { + + private final MainQuery mainQuery; + private final Set ctes; + private boolean recursive = false; + + CTEManager(MainQuery mainQuery) { + this.mainQuery = mainQuery; + this.ctes = new LinkedHashSet(); + } + + Set getCtes() { + return ctes; + } + + public boolean hasCtes() { + return ctes.size() > 0; + } + + boolean isRecursive() { + return recursive; + } + + void buildClause(StringBuilder sb) { + if (ctes.isEmpty()) { + return; + } + + sb.append("WITH "); + + if (recursive) { + sb.append("RECURSIVE "); + } + + boolean first = true; + for (CTEInfo cte : ctes) { + if (first) { + first = false; + } else { + sb.append(", "); + } + + sb.append(cte.name); + sb.append('('); + + final List attributes = cte.attributes; + sb.append(attributes.get(0)); + + for (int i = 1; i < attributes.size(); i++) { + sb.append(", "); + sb.append(attributes.get(i)); + } + + sb.append(')'); + + sb.append(" AS(\n"); + sb.append(cte.nonRecursiveCriteriaBuilder.getQueryString()); + + if (cte.recursive) { + sb.append("\nUNION ALL\n"); + sb.append(cte.recursiveCriteriaBuilder.getQueryString()); + } + + sb.append("\n)"); + } + + sb.append("\n"); + } + + @SuppressWarnings("unchecked") + StartOngoingSetOperationCTECriteriaBuilder> withStartSet(Class cteClass, Y result) { + String cteName = cteClass.getSimpleName(); + FinalSetOperationCTECriteriaBuilderImpl parentFinalSetOperationBuilder = new FinalSetOperationCTECriteriaBuilderImpl(mainQuery, (Class) cteClass, result, null, false, this, null); + OngoingFinalSetOperationCTECriteriaBuilderImpl subFinalSetOperationBuilder = new OngoingFinalSetOperationCTECriteriaBuilderImpl(mainQuery, (Class) cteClass, null, null, true, parentFinalSetOperationBuilder.getSubListener(), null); + this.onBuilderStarted(parentFinalSetOperationBuilder); + + LeafOngoingSetOperationCTECriteriaBuilderImpl leafCb = new LeafOngoingSetOperationCTECriteriaBuilderImpl(mainQuery, cteName, (Class) cteClass, result, parentFinalSetOperationBuilder.getSubListener(), (FinalSetOperationCTECriteriaBuilderImpl) parentFinalSetOperationBuilder); + OngoingSetOperationCTECriteriaBuilderImpl> cb = new OngoingSetOperationCTECriteriaBuilderImpl>(mainQuery, cteName, (Class) cteClass, result, subFinalSetOperationBuilder.getSubListener(), (OngoingFinalSetOperationCTECriteriaBuilderImpl) subFinalSetOperationBuilder, leafCb); + + subFinalSetOperationBuilder.setOperationManager.setStartQueryBuilder(cb); + parentFinalSetOperationBuilder.setOperationManager.setStartQueryBuilder(subFinalSetOperationBuilder); + + subFinalSetOperationBuilder.getSubListener().onBuilderStarted(cb); + parentFinalSetOperationBuilder.getSubListener().onBuilderStarted(leafCb); + + return cb; + } + + @SuppressWarnings("unchecked") + FullSelectCTECriteriaBuilder with(Class cteClass, Y result) { + String cteName = cteClass.getSimpleName(); + FullSelectCTECriteriaBuilderImpl cteBuilder = new FullSelectCTECriteriaBuilderImpl(mainQuery, cteName, (Class) cteClass, result, this); + this.onBuilderStarted(cteBuilder); + return cteBuilder; + } + + @SuppressWarnings("unchecked") + SelectRecursiveCTECriteriaBuilder withRecursive(Class cteClass, Y result) { + String cteName = cteClass.getSimpleName(); + recursive = true; + RecursiveCTECriteriaBuilderImpl cteBuilder = new RecursiveCTECriteriaBuilderImpl(mainQuery, cteName, (Class) cteClass, result, this); + this.onBuilderStarted(cteBuilder); + return cteBuilder; + } + + ReturningModificationCriteriaBuilderFactory withReturning(Class cteClass, Y result) { + String cteName = cteClass.getSimpleName(); + ReturningModificationCriteraBuilderFactoryImpl factory = new ReturningModificationCriteraBuilderFactoryImpl(mainQuery, cteName, cteClass, result, this); + return factory; + } + + @Override + public void onBuilderEnded(CTEInfoBuilder builder) { + super.onBuilderEnded(builder); + CTEInfo cteInfo = builder.createCTEInfo(); + ctes.add(cteInfo); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationProviderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationProviderImpl.java index 8e43debad9..5cf84b568c 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationProviderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationProviderImpl.java @@ -1,43 +1,43 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.logging.Logger; - -import com.blazebit.persistence.spi.CriteriaBuilderConfiguration; -import com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class CriteriaBuilderConfigurationProviderImpl implements CriteriaBuilderConfigurationProvider { - - private static final Logger log = Logger.getLogger(CriteriaBuilderConfigurationProviderImpl.class.getName()); - private static volatile boolean versionLogged = false; - - @Override - public CriteriaBuilderConfiguration createConfiguration() { - if (!versionLogged) { - log.info("Blaze-Persistence version: " + Version.printVersion()); - versionLogged = true; - } - - return new CriteriaBuilderConfigurationImpl(); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.logging.Logger; + +import com.blazebit.persistence.spi.CriteriaBuilderConfiguration; +import com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class CriteriaBuilderConfigurationProviderImpl implements CriteriaBuilderConfigurationProvider { + + private static final Logger log = Logger.getLogger(CriteriaBuilderConfigurationProviderImpl.class.getName()); + private static volatile boolean versionLogged = false; + + @Override + public CriteriaBuilderConfiguration createConfiguration() { + if (!versionLogged) { + log.info("Blaze-Persistence version: " + Version.printVersion()); + versionLogged = true; + } + + return new CriteriaBuilderConfigurationImpl(); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderImpl.java index 4cc5939d3b..88e04ea67c 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderImpl.java @@ -1,93 +1,93 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.CriteriaBuilder; -import com.blazebit.persistence.LeafOngoingSetOperationCriteriaBuilder; -import com.blazebit.persistence.ObjectBuilder; -import com.blazebit.persistence.SelectObjectBuilder; -import com.blazebit.persistence.StartOngoingSetOperationCriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class CriteriaBuilderImpl extends AbstractFullQueryBuilder, LeafOngoingSetOperationCriteriaBuilder, StartOngoingSetOperationCriteriaBuilder>, BaseFinalSetOperationCriteriaBuilderImpl> implements CriteriaBuilder { - - public CriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias) { - super(mainQuery, isMainQuery, clazz, alias, null); - } - - @Override - @SuppressWarnings("unchecked") - public SelectObjectBuilder> selectNew(Class clazz) { - return (SelectObjectBuilder>) super.selectNew(clazz); - } - - @Override - @SuppressWarnings("unchecked") - public CriteriaBuilder selectNew(ObjectBuilder builder) { - return (CriteriaBuilder) super.selectNew(builder); - } - - @Override - protected BaseFinalSetOperationCriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - boolean wasMainQuery = isMainQuery; - this.isMainQuery = false; - BuilderListener newListener = finalSetOperationBuilder == null ? null : finalSetOperationBuilder.getSubListener(); - - if (nested) { - return new OngoingFinalSetOperationCriteriaBuilderImpl(mainQuery, wasMainQuery, resultType, operator, nested, newListener); - } else { - return new FinalSetOperationCriteriaBuilderImpl(mainQuery, wasMainQuery, resultType, operator, nested, newListener); - } - } - - @Override - protected LeafOngoingSetOperationCriteriaBuilder createSetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { - return createLeaf(finalSetOperationBuilder); - } - - @Override - protected StartOngoingSetOperationCriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCriteriaBuilderImpl resultFinalSetOperationBuilder) { - LeafOngoingSetOperationCriteriaBuilder leafCb = createLeaf(resultFinalSetOperationBuilder); - return createOngoing(finalSetOperationBuilder, leafCb); - } - - @SuppressWarnings("unchecked") - private LeafOngoingSetOperationCriteriaBuilderImpl createLeaf(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { - BuilderListener newListener = finalSetOperationBuilder.getSubListener(); - LeafOngoingSetOperationCriteriaBuilderImpl next = new LeafOngoingSetOperationCriteriaBuilderImpl(mainQuery, false, resultType, newListener, (FinalSetOperationCriteriaBuilderImpl) finalSetOperationBuilder); - newListener.onBuilderStarted(next); - return next; - } - - @SuppressWarnings("unchecked") - private OngoingSetOperationCriteriaBuilderImpl createOngoing(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, Y endSetResult) { - // TODO: This is such an ugly hack, but I don't know how else to fix this generics issue for now - finalSetOperationBuilder.setEndSetResult((T) endSetResult); - - BuilderListener newListener = finalSetOperationBuilder.getSubListener(); - OngoingSetOperationCriteriaBuilderImpl next = new OngoingSetOperationCriteriaBuilderImpl(mainQuery, false, resultType, newListener, (OngoingFinalSetOperationCriteriaBuilderImpl) finalSetOperationBuilder, endSetResult); - newListener.onBuilderStarted(next); - return next; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.CriteriaBuilder; +import com.blazebit.persistence.LeafOngoingSetOperationCriteriaBuilder; +import com.blazebit.persistence.ObjectBuilder; +import com.blazebit.persistence.SelectObjectBuilder; +import com.blazebit.persistence.StartOngoingSetOperationCriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class CriteriaBuilderImpl extends AbstractFullQueryBuilder, LeafOngoingSetOperationCriteriaBuilder, StartOngoingSetOperationCriteriaBuilder>, BaseFinalSetOperationCriteriaBuilderImpl> implements CriteriaBuilder { + + public CriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, String alias) { + super(mainQuery, isMainQuery, clazz, alias, null); + } + + @Override + @SuppressWarnings("unchecked") + public SelectObjectBuilder> selectNew(Class clazz) { + return (SelectObjectBuilder>) super.selectNew(clazz); + } + + @Override + @SuppressWarnings("unchecked") + public CriteriaBuilder selectNew(ObjectBuilder builder) { + return (CriteriaBuilder) super.selectNew(builder); + } + + @Override + protected BaseFinalSetOperationCriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + boolean wasMainQuery = isMainQuery; + this.isMainQuery = false; + BuilderListener newListener = finalSetOperationBuilder == null ? null : finalSetOperationBuilder.getSubListener(); + + if (nested) { + return new OngoingFinalSetOperationCriteriaBuilderImpl(mainQuery, wasMainQuery, resultType, operator, nested, newListener); + } else { + return new FinalSetOperationCriteriaBuilderImpl(mainQuery, wasMainQuery, resultType, operator, nested, newListener); + } + } + + @Override + protected LeafOngoingSetOperationCriteriaBuilder createSetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { + return createLeaf(finalSetOperationBuilder); + } + + @Override + protected StartOngoingSetOperationCriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCriteriaBuilderImpl resultFinalSetOperationBuilder) { + LeafOngoingSetOperationCriteriaBuilder leafCb = createLeaf(resultFinalSetOperationBuilder); + return createOngoing(finalSetOperationBuilder, leafCb); + } + + @SuppressWarnings("unchecked") + private LeafOngoingSetOperationCriteriaBuilderImpl createLeaf(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { + BuilderListener newListener = finalSetOperationBuilder.getSubListener(); + LeafOngoingSetOperationCriteriaBuilderImpl next = new LeafOngoingSetOperationCriteriaBuilderImpl(mainQuery, false, resultType, newListener, (FinalSetOperationCriteriaBuilderImpl) finalSetOperationBuilder); + newListener.onBuilderStarted(next); + return next; + } + + @SuppressWarnings("unchecked") + private OngoingSetOperationCriteriaBuilderImpl createOngoing(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, Y endSetResult) { + // TODO: This is such an ugly hack, but I don't know how else to fix this generics issue for now + finalSetOperationBuilder.setEndSetResult((T) endSetResult); + + BuilderListener newListener = finalSetOperationBuilder.getSubListener(); + OngoingSetOperationCriteriaBuilderImpl next = new OngoingSetOperationCriteriaBuilderImpl(mainQuery, false, resultType, newListener, (OngoingFinalSetOperationCriteriaBuilderImpl) finalSetOperationBuilder, endSetResult); + newListener.onBuilderStarted(next); + return next; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/DefaultOrderByElement.java b/core/impl/src/main/java/com/blazebit/persistence/impl/DefaultOrderByElement.java index ad55e072e7..64d2153461 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/DefaultOrderByElement.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/DefaultOrderByElement.java @@ -1,71 +1,71 @@ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.spi.OrderByElement; - - -public class DefaultOrderByElement implements OrderByElement { - - private final String name; - private final int position; - private final boolean ascending; - private final boolean nullsFirst; - - public DefaultOrderByElement(String name, int position, boolean ascending, boolean nullsFirst) { - this.name = name; - this.position = position; - this.ascending = ascending; - this.nullsFirst = nullsFirst; - } - - public String getName() { - return name; - } - - @Override - public int getPosition() { - return position; - } - - @Override - public boolean isAscending() { - return ascending; - } - - @Override - public boolean isNullsFirst() { - return nullsFirst; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(20); - sb.append(position); - - if (ascending) { - sb.append(" ASC"); - } else { - sb.append(" DESC"); - } - - if (nullsFirst) { - sb.append(" NULLS FIRST"); - } else { - sb.append(" NULLS LAST"); - } - - return sb.toString(); - } - - public static OrderByElement fromString(String string) { - return fromString(string, 0, string.length() - 1); - } - - public static OrderByElement fromString(String string, int startIndex, int endIndex) { - int spaceIndex = string.indexOf(' ', startIndex); - int pos = Integer.parseInt(string.substring(startIndex, spaceIndex)); - boolean asc = string.charAt(spaceIndex + 1) == 'A'; - spaceIndex = string.lastIndexOf(' ', endIndex); - boolean nullFirst = string.charAt(spaceIndex + 1) == 'F'; - return new DefaultOrderByElement(null, pos, asc, nullFirst); - } -} +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.spi.OrderByElement; + + +public class DefaultOrderByElement implements OrderByElement { + + private final String name; + private final int position; + private final boolean ascending; + private final boolean nullsFirst; + + public DefaultOrderByElement(String name, int position, boolean ascending, boolean nullsFirst) { + this.name = name; + this.position = position; + this.ascending = ascending; + this.nullsFirst = nullsFirst; + } + + public String getName() { + return name; + } + + @Override + public int getPosition() { + return position; + } + + @Override + public boolean isAscending() { + return ascending; + } + + @Override + public boolean isNullsFirst() { + return nullsFirst; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(20); + sb.append(position); + + if (ascending) { + sb.append(" ASC"); + } else { + sb.append(" DESC"); + } + + if (nullsFirst) { + sb.append(" NULLS FIRST"); + } else { + sb.append(" NULLS LAST"); + } + + return sb.toString(); + } + + public static OrderByElement fromString(String string) { + return fromString(string, 0, string.length() - 1); + } + + public static OrderByElement fromString(String string, int startIndex, int endIndex) { + int spaceIndex = string.indexOf(' ', startIndex); + int pos = Integer.parseInt(string.substring(startIndex, spaceIndex)); + boolean asc = string.charAt(spaceIndex + 1) == 'A'; + spaceIndex = string.lastIndexOf(' ', endIndex); + boolean nullFirst = string.charAt(spaceIndex + 1) == 'F'; + return new DefaultOrderByElement(null, pos, asc, nullFirst); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/DeleteCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/DeleteCriteriaBuilderImpl.java index b3bef09381..3863a19c77 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/DeleteCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/DeleteCriteriaBuilderImpl.java @@ -1,32 +1,32 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.DeleteCriteriaBuilder; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class DeleteCriteriaBuilderImpl extends BaseDeleteCriteriaBuilderImpl, Void> implements DeleteCriteriaBuilder { - - public DeleteCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String alias) { - super(mainQuery, true, clazz, alias, null, null, null, null); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.DeleteCriteriaBuilder; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class DeleteCriteriaBuilderImpl extends BaseDeleteCriteriaBuilderImpl, Void> implements DeleteCriteriaBuilder { + + public DeleteCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String alias) { + super(mainQuery, true, clazz, alias, null, null, null, null); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/EntitySelectResolveVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/EntitySelectResolveVisitor.java index 197f1c7cd1..36530433af 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/EntitySelectResolveVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/EntitySelectResolveVisitor.java @@ -1,107 +1,107 @@ -package com.blazebit.persistence.impl; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.persistence.FetchType; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.Metamodel; - -import com.blazebit.persistence.impl.expression.AggregateExpression; -import com.blazebit.persistence.impl.expression.FunctionExpression; -import com.blazebit.persistence.impl.expression.PathElementExpression; -import com.blazebit.persistence.impl.expression.PathExpression; -import com.blazebit.persistence.impl.expression.SimplePathReference; -import com.blazebit.persistence.impl.expression.VisitorAdapter; - -/** - * This visitor resolves entity references to their attributes. This is needed for entity references - * in the select clause when used in combination with aggregate functions. We have to decompose the - * entity and add the components to the group by because all component will end up in the select clause. - * - * @author Christian Beikov - * @since 1.0.5 - */ -public class EntitySelectResolveVisitor extends VisitorAdapter { - - private final Metamodel m; - private final Set pathExpressions; - - public EntitySelectResolveVisitor(Metamodel m) { - this(m, new LinkedHashSet()); - } - - public EntitySelectResolveVisitor(Metamodel m, Set pathExpressions) { - this.m = m; - this.pathExpressions = pathExpressions; - } - - public Set getPathExpressions() { - return pathExpressions; - } - - @Override - public void visit(FunctionExpression expression) { - if (!(expression instanceof AggregateExpression)) { - super.visit(expression); - } - } - - @Override - public void visit(PathExpression expression) { - if (expression.getField() == null) { - /** - * We need to resolve entity selects because hibernate will - * select every entity attribute. Since we need every select in - * the group by (because of DB2) we need to resolve such entity - * selects here - */ - JoinNode baseNode = ((JoinNode) expression.getBaseNode()); - EntityType entityType; - - try { - entityType = m.entity(baseNode.getPropertyClass()); - } catch (IllegalArgumentException e) { - // ignore if the expression is not an entity - return; - } - - // we need to ensure a deterministic order for testing - SortedSet> sortedAttributes = new TreeSet>(new Comparator>() { - - @Override - public int compare(Attribute o1, Attribute o2) { - return o1.getName().compareTo(o2.getName()); - } - - }); - sortedAttributes.addAll(entityType.getAttributes()); - for (Attribute attr : sortedAttributes) { - boolean resolve = false; - if (ExpressionUtils.isAssociation(attr) && !attr.isCollection()) { - resolve = true; - } else if (ExpressionUtils.getFetchType(attr) == FetchType.EAGER) { - if (attr.getPersistentAttributeType() == Attribute.PersistentAttributeType.ELEMENT_COLLECTION) { - throw new UnsupportedOperationException("Eager element collections are not supported"); - } - resolve = true; - } - - if (resolve) { - PathExpression attrPath = new PathExpression(new ArrayList(expression.getExpressions())); - attrPath.setPathReference(new SimplePathReference(baseNode, attr.getName())); - pathExpressions.add(attrPath); - } - } - } - } - - public void resolve(JoinNode baseNode) { - - } +package com.blazebit.persistence.impl; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.persistence.FetchType; +import javax.persistence.metamodel.Attribute; +import javax.persistence.metamodel.EntityType; +import javax.persistence.metamodel.Metamodel; + +import com.blazebit.persistence.impl.expression.AggregateExpression; +import com.blazebit.persistence.impl.expression.FunctionExpression; +import com.blazebit.persistence.impl.expression.PathElementExpression; +import com.blazebit.persistence.impl.expression.PathExpression; +import com.blazebit.persistence.impl.expression.SimplePathReference; +import com.blazebit.persistence.impl.expression.VisitorAdapter; + +/** + * This visitor resolves entity references to their attributes. This is needed for entity references + * in the select clause when used in combination with aggregate functions. We have to decompose the + * entity and add the components to the group by because all component will end up in the select clause. + * + * @author Christian Beikov + * @since 1.0.5 + */ +public class EntitySelectResolveVisitor extends VisitorAdapter { + + private final Metamodel m; + private final Set pathExpressions; + + public EntitySelectResolveVisitor(Metamodel m) { + this(m, new LinkedHashSet()); + } + + public EntitySelectResolveVisitor(Metamodel m, Set pathExpressions) { + this.m = m; + this.pathExpressions = pathExpressions; + } + + public Set getPathExpressions() { + return pathExpressions; + } + + @Override + public void visit(FunctionExpression expression) { + if (!(expression instanceof AggregateExpression)) { + super.visit(expression); + } + } + + @Override + public void visit(PathExpression expression) { + if (expression.getField() == null) { + /** + * We need to resolve entity selects because hibernate will + * select every entity attribute. Since we need every select in + * the group by (because of DB2) we need to resolve such entity + * selects here + */ + JoinNode baseNode = ((JoinNode) expression.getBaseNode()); + EntityType entityType; + + try { + entityType = m.entity(baseNode.getPropertyClass()); + } catch (IllegalArgumentException e) { + // ignore if the expression is not an entity + return; + } + + // we need to ensure a deterministic order for testing + SortedSet> sortedAttributes = new TreeSet>(new Comparator>() { + + @Override + public int compare(Attribute o1, Attribute o2) { + return o1.getName().compareTo(o2.getName()); + } + + }); + sortedAttributes.addAll(entityType.getAttributes()); + for (Attribute attr : sortedAttributes) { + boolean resolve = false; + if (ExpressionUtils.isAssociation(attr) && !attr.isCollection()) { + resolve = true; + } else if (ExpressionUtils.getFetchType(attr) == FetchType.EAGER) { + if (attr.getPersistentAttributeType() == Attribute.PersistentAttributeType.ELEMENT_COLLECTION) { + throw new UnsupportedOperationException("Eager element collections are not supported"); + } + resolve = true; + } + + if (resolve) { + PathExpression attrPath = new PathExpression(new ArrayList(expression.getExpressions())); + attrPath.setPathReference(new SimplePathReference(baseNode, attr.getName())); + pathExpressions.add(attrPath); + } + } + } + } + + public void resolve(JoinNode baseNode) { + + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ExpressionTransformer.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ExpressionTransformer.java index d393460893..cb1554e5a5 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ExpressionTransformer.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ExpressionTransformer.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public interface ExpressionTransformer { - - public Expression transform(Expression original, ClauseType fromClause, boolean joinRequired); - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public interface ExpressionTransformer { + + public Expression transform(Expression original, ClauseType fromClause, boolean joinRequired); + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ExternalAliasDereferencingException.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ExternalAliasDereferencingException.java index 1d50c6e48c..e162030d42 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ExternalAliasDereferencingException.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ExternalAliasDereferencingException.java @@ -1,41 +1,41 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class ExternalAliasDereferencingException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public ExternalAliasDereferencingException() { - } - - public ExternalAliasDereferencingException(String msg) { - super(msg); - } - - public ExternalAliasDereferencingException(Throwable t) { - super(t); - } - - public ExternalAliasDereferencingException(String msg, Throwable t) { - super(msg, t); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class ExternalAliasDereferencingException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public ExternalAliasDereferencingException() { + } + + public ExternalAliasDereferencingException(String msg) { + super(msg); + } + + public ExternalAliasDereferencingException(Throwable t) { + super(t); + } + + public ExternalAliasDereferencingException(String msg, Throwable t) { + super(msg, t); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationCTECriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationCTECriteriaBuilderImpl.java index d86329b894..c96e53d881 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationCTECriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationCTECriteriaBuilderImpl.java @@ -1,40 +1,40 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.FinalSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class FinalSetOperationCTECriteriaBuilderImpl extends BaseFinalSetOperationCTECriteriaBuilderImpl> implements FinalSetOperationCTECriteriaBuilder, CTEInfoBuilder { - - public FinalSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, Class clazz, T result, SetOperationType operator, boolean nested, CTEBuilderListener listener, FullSelectCTECriteriaBuilderImpl initiator) { - super(mainQuery, clazz, result, operator, nested, listener, initiator); - } - - @Override - public T end() { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return result; - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.FinalSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class FinalSetOperationCTECriteriaBuilderImpl extends BaseFinalSetOperationCTECriteriaBuilderImpl> implements FinalSetOperationCTECriteriaBuilder, CTEInfoBuilder { + + public FinalSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, Class clazz, T result, SetOperationType operator, boolean nested, CTEBuilderListener listener, FullSelectCTECriteriaBuilderImpl initiator) { + super(mainQuery, clazz, result, operator, nested, listener, initiator); + } + + @Override + public T end() { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return result; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationCriteriaBuilderImpl.java index 23ce24def7..9d7b33e5f2 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationCriteriaBuilderImpl.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.FinalSetOperationCriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class FinalSetOperationCriteriaBuilderImpl extends BaseFinalSetOperationCriteriaBuilderImpl> implements FinalSetOperationCriteriaBuilder { - - - public FinalSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, SetOperationType operator, boolean nested, BuilderListener listener) { - super(mainQuery, isMainQuery, clazz, operator, nested, listener, null); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.FinalSetOperationCriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class FinalSetOperationCriteriaBuilderImpl extends BaseFinalSetOperationCriteriaBuilderImpl> implements FinalSetOperationCriteriaBuilder { + + + public FinalSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, SetOperationType operator, boolean nested, BuilderListener listener) { + super(mainQuery, isMainQuery, clazz, operator, nested, listener, null); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationSubqueryBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationSubqueryBuilderImpl.java index c0b60a74da..251aafb7dd 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationSubqueryBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/FinalSetOperationSubqueryBuilderImpl.java @@ -1,40 +1,40 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.FinalSetOperationSubqueryBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class FinalSetOperationSubqueryBuilderImpl extends BaseFinalSetOperationSubqueryBuilderImpl> implements FinalSetOperationSubqueryBuilder { - - public FinalSetOperationSubqueryBuilderImpl(MainQuery mainQuery, T result, SetOperationType operator, boolean nested, SubqueryBuilderListener listener, SubqueryBuilderImpl initiator) { - super(mainQuery, result, operator, nested, listener, initiator); - } - - @Override - public T end() { - subListener.verifySubqueryBuilderEnded(); - listener.onBuilderEnded(this); - return result; - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.FinalSetOperationSubqueryBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class FinalSetOperationSubqueryBuilderImpl extends BaseFinalSetOperationSubqueryBuilderImpl> implements FinalSetOperationSubqueryBuilder { + + public FinalSetOperationSubqueryBuilderImpl(MainQuery mainQuery, T result, SetOperationType operator, boolean nested, SubqueryBuilderListener listener, SubqueryBuilderImpl initiator) { + super(mainQuery, result, operator, nested, listener, initiator); + } + + @Override + public T end() { + subListener.verifySubqueryBuilderEnded(); + listener.onBuilderEnded(this); + return result; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/FullSelectCTECriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/FullSelectCTECriteriaBuilderImpl.java index 9a59384aaf..9488a02dd5 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/FullSelectCTECriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/FullSelectCTECriteriaBuilderImpl.java @@ -1,55 +1,55 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.FullSelectCTECriteriaBuilder; -import com.blazebit.persistence.LeafOngoingSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.StartOngoingSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class FullSelectCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, LeafOngoingSetOperationCTECriteriaBuilder, StartOngoingSetOperationCTECriteriaBuilder>> implements FullSelectCTECriteriaBuilder { - - public FullSelectCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, T result, CTEBuilderListener listener) { - super(mainQuery, cteName, clazz, result, listener, null); - } - - @Override - protected BaseFinalSetOperationCTECriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - return createFinalSetOperationBuilder(operator, nested, nested, this); - } - - @Override - protected LeafOngoingSetOperationCTECriteriaBuilder createSetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onReplaceBuilder(this, finalSetOperationBuilder); - return createLeaf(finalSetOperationBuilder); - } - - @Override - protected StartOngoingSetOperationCTECriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCTECriteriaBuilderImpl resultFinalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onReplaceBuilder(this, resultFinalSetOperationBuilder); - LeafOngoingSetOperationCTECriteriaBuilder leafCb = createSetOperand(resultFinalSetOperationBuilder); - return createOngoing(finalSetOperationBuilder, leafCb); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.FullSelectCTECriteriaBuilder; +import com.blazebit.persistence.LeafOngoingSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.StartOngoingSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class FullSelectCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, LeafOngoingSetOperationCTECriteriaBuilder, StartOngoingSetOperationCTECriteriaBuilder>> implements FullSelectCTECriteriaBuilder { + + public FullSelectCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, T result, CTEBuilderListener listener) { + super(mainQuery, cteName, clazz, result, listener, null); + } + + @Override + protected BaseFinalSetOperationCTECriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + return createFinalSetOperationBuilder(operator, nested, nested, this); + } + + @Override + protected LeafOngoingSetOperationCTECriteriaBuilder createSetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onReplaceBuilder(this, finalSetOperationBuilder); + return createLeaf(finalSetOperationBuilder); + } + + @Override + protected StartOngoingSetOperationCTECriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCTECriteriaBuilderImpl resultFinalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onReplaceBuilder(this, resultFinalSetOperationBuilder); + LeafOngoingSetOperationCTECriteriaBuilder leafCb = createSetOperand(resultFinalSetOperationBuilder); + return createOngoing(finalSetOperationBuilder, leafCb); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/IllegalSubqueryDetector.java b/core/impl/src/main/java/com/blazebit/persistence/impl/IllegalSubqueryDetector.java index e322434fad..f3cb198484 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/IllegalSubqueryDetector.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/IllegalSubqueryDetector.java @@ -1,72 +1,72 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.PathExpression; -import com.blazebit.persistence.impl.expression.SubqueryExpression; -import com.blazebit.persistence.impl.expression.VisitorAdapter; - -/** - * - * @author Moritz Becker - * @author Christian Beikov - * @since 1.0 - */ -public class IllegalSubqueryDetector extends VisitorAdapter { - - private final AliasManager aliasManager; - private boolean inSubquery = false; - - public IllegalSubqueryDetector(AliasManager aliasManager) { - this.aliasManager = aliasManager; - } - - @Override - public void visit(PathExpression expression) { - AliasInfo aliasInfo = aliasManager.getAliasInfo(expression.toString()); - - if (aliasInfo != null && aliasInfo instanceof SelectInfo) { - ((SelectInfo) aliasInfo).getExpression().accept(this); - } else if (inSubquery) { - JoinNode joinNode = (JoinNode) expression.getBaseNode(); - - if (joinNode != null && joinNode.getAliasInfo().getAliasOwner() == aliasManager) { - // we have an external path in the subquery - while (joinNode != null && joinNode.getParentTreeNode() != null) { - if (joinNode.getParentTreeNode().isCollection()) { - throw new IllegalStateException("Unsupported external collection access [" + joinNode.getAliasInfo().getAbsolutePath() - + "]"); - } - - joinNode = joinNode.getParent(); - } - } - } - } - - @Override - public void visit(SubqueryExpression expression) { - boolean inSubqueryCpy = inSubquery; - inSubquery = true; - // TODO: this is ugly - AbstractCommonQueryBuilder builder = (AbstractCommonQueryBuilder) expression.getSubquery(); - builder.applyVisitor(this); - - if (!inSubqueryCpy) { - inSubquery = false; - } - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.PathExpression; +import com.blazebit.persistence.impl.expression.SubqueryExpression; +import com.blazebit.persistence.impl.expression.VisitorAdapter; + +/** + * + * @author Moritz Becker + * @author Christian Beikov + * @since 1.0 + */ +public class IllegalSubqueryDetector extends VisitorAdapter { + + private final AliasManager aliasManager; + private boolean inSubquery = false; + + public IllegalSubqueryDetector(AliasManager aliasManager) { + this.aliasManager = aliasManager; + } + + @Override + public void visit(PathExpression expression) { + AliasInfo aliasInfo = aliasManager.getAliasInfo(expression.toString()); + + if (aliasInfo != null && aliasInfo instanceof SelectInfo) { + ((SelectInfo) aliasInfo).getExpression().accept(this); + } else if (inSubquery) { + JoinNode joinNode = (JoinNode) expression.getBaseNode(); + + if (joinNode != null && joinNode.getAliasInfo().getAliasOwner() == aliasManager) { + // we have an external path in the subquery + while (joinNode != null && joinNode.getParentTreeNode() != null) { + if (joinNode.getParentTreeNode().isCollection()) { + throw new IllegalStateException("Unsupported external collection access [" + joinNode.getAliasInfo().getAbsolutePath() + + "]"); + } + + joinNode = joinNode.getParent(); + } + } + } + } + + @Override + public void visit(SubqueryExpression expression) { + boolean inSubqueryCpy = inSubquery; + inSubquery = true; + // TODO: this is ugly + AbstractCommonQueryBuilder builder = (AbstractCommonQueryBuilder) expression.getSubquery(); + builder.applyVisitor(this); + + if (!inSubqueryCpy) { + inSubquery = false; + } + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/InsertCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/InsertCriteriaBuilderImpl.java index 390d8f5e76..c315a4fdbe 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/InsertCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/InsertCriteriaBuilderImpl.java @@ -1,32 +1,32 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.InsertCriteriaBuilder; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class InsertCriteriaBuilderImpl extends BaseInsertCriteriaBuilderImpl, Void> implements InsertCriteriaBuilder { - - public InsertCriteriaBuilderImpl(MainQuery mainQuery, Class clazz) { - super(mainQuery, true, clazz, null, null, null, null); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.InsertCriteriaBuilder; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class InsertCriteriaBuilderImpl extends BaseInsertCriteriaBuilderImpl, Void> implements InsertCriteriaBuilder { + + public InsertCriteriaBuilderImpl(MainQuery mainQuery, Class clazz) { + super(mainQuery, true, clazz, null, null, null, null); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/JoinAliasInfo.java b/core/impl/src/main/java/com/blazebit/persistence/impl/JoinAliasInfo.java index c609f4582f..65da3aabdd 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/JoinAliasInfo.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/JoinAliasInfo.java @@ -1,77 +1,77 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class JoinAliasInfo implements AliasInfo { - - private String alias; - private JoinNode joinNode; - private boolean implicit; - // The absolute normalized path with the root as implicit base - private final String absolutePath; - private final AliasManager aliasOwner; - - public JoinAliasInfo(String alias, String absolutePath, boolean implicit, AliasManager aliasOwner) { - this.alias = alias; - this.absolutePath = absolutePath; - this.implicit = implicit; - this.aliasOwner = aliasOwner; - } - - @Override - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public JoinNode getJoinNode() { - return joinNode; - } - - public void setJoinNode(JoinNode joinNode) { - this.joinNode = joinNode; - } - - public String getAbsolutePath() { - if (implicit) { - return absolutePath; - } else { - return alias; - } - } - - public boolean isImplicit() { - return implicit; - } - - public void setImplicit(boolean implicit) { - this.implicit = implicit; - } - - @Override - public AliasManager getAliasOwner() { - return this.aliasOwner; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class JoinAliasInfo implements AliasInfo { + + private String alias; + private JoinNode joinNode; + private boolean implicit; + // The absolute normalized path with the root as implicit base + private final String absolutePath; + private final AliasManager aliasOwner; + + public JoinAliasInfo(String alias, String absolutePath, boolean implicit, AliasManager aliasOwner) { + this.alias = alias; + this.absolutePath = absolutePath; + this.implicit = implicit; + this.aliasOwner = aliasOwner; + } + + @Override + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public JoinNode getJoinNode() { + return joinNode; + } + + public void setJoinNode(JoinNode joinNode) { + this.joinNode = joinNode; + } + + public String getAbsolutePath() { + if (implicit) { + return absolutePath; + } else { + return alias; + } + } + + public boolean isImplicit() { + return implicit; + } + + public void setImplicit(boolean implicit) { + this.implicit = implicit; + } + + @Override + public AliasManager getAliasOwner() { + return this.aliasOwner; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/JoinNodeVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/JoinNodeVisitor.java index 26ab59f774..67b139a86a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/JoinNodeVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/JoinNodeVisitor.java @@ -1,27 +1,27 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public interface JoinNodeVisitor { - - public void visit(JoinNode node); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public interface JoinNodeVisitor { + + public void visit(JoinNode node); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/JoinTreeNode.java b/core/impl/src/main/java/com/blazebit/persistence/impl/JoinTreeNode.java index 96cf3172d7..5841b70118 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/JoinTreeNode.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/JoinTreeNode.java @@ -1,97 +1,97 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.Map; -import java.util.TreeMap; - -import javax.persistence.metamodel.Attribute; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class JoinTreeNode { - - private final String relationName; - private final Attribute attribute; - private JoinNode defaultNode; - private final boolean collection; - private final boolean map; - private final boolean optional; - /* maps join aliases to join nodes */ - private final Map joinNodes = new TreeMap(); - - public JoinTreeNode(String relationName, Attribute attribute) { - this.relationName = relationName; - this.attribute = attribute; - this.collection = attribute.isCollection(); - this.map = JpaUtils.isMap(attribute); - this.optional = JpaUtils.isOptional(attribute); - } - - public String getRelationName() { - return relationName; - } - - public Attribute getAttribute() { - return attribute; - } - - public JoinNode getDefaultNode() { - return defaultNode; - } - - public void setDefaultNode(JoinNode defaultNode) { - this.defaultNode = defaultNode; - } - - public Map getJoinNodes() { - return joinNodes; - } - - public JoinNode getJoinNode(String alias, boolean defaultJoin) { - if (defaultJoin) { - return defaultNode; - } else { - return joinNodes.get(alias); - } - } - - public void addJoinNode(JoinNode node, boolean defaultJoin) { - if (defaultJoin) { - if (defaultNode != null) { - throw new IllegalStateException("Tried to add a default node to the tree node although one already exists!"); - } - defaultNode = node; - } - - joinNodes.put(node.getAliasInfo().getAlias(), node); - } - - public boolean isCollection() { - return collection; - } - - public boolean isMap() { - return map; - } - - public boolean isOptional() { - return optional; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.Map; +import java.util.TreeMap; + +import javax.persistence.metamodel.Attribute; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class JoinTreeNode { + + private final String relationName; + private final Attribute attribute; + private JoinNode defaultNode; + private final boolean collection; + private final boolean map; + private final boolean optional; + /* maps join aliases to join nodes */ + private final Map joinNodes = new TreeMap(); + + public JoinTreeNode(String relationName, Attribute attribute) { + this.relationName = relationName; + this.attribute = attribute; + this.collection = attribute.isCollection(); + this.map = JpaUtils.isMap(attribute); + this.optional = JpaUtils.isOptional(attribute); + } + + public String getRelationName() { + return relationName; + } + + public Attribute getAttribute() { + return attribute; + } + + public JoinNode getDefaultNode() { + return defaultNode; + } + + public void setDefaultNode(JoinNode defaultNode) { + this.defaultNode = defaultNode; + } + + public Map getJoinNodes() { + return joinNodes; + } + + public JoinNode getJoinNode(String alias, boolean defaultJoin) { + if (defaultJoin) { + return defaultNode; + } else { + return joinNodes.get(alias); + } + } + + public void addJoinNode(JoinNode node, boolean defaultJoin) { + if (defaultJoin) { + if (defaultNode != null) { + throw new IllegalStateException("Tried to add a default node to the tree node although one already exists!"); + } + defaultNode = node; + } + + joinNodes.put(node.getAliasInfo().getAlias(), node); + } + + public boolean isCollection() { + return collection; + } + + public boolean isMap() { + return map; + } + + public boolean isOptional() { + return optional; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/JoinVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/JoinVisitor.java index 9ad9b6f73e..56c67a00ab 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/JoinVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/JoinVisitor.java @@ -1,134 +1,134 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.FunctionExpression; -import com.blazebit.persistence.impl.expression.PathExpression; -import com.blazebit.persistence.impl.expression.SubqueryExpression; -import com.blazebit.persistence.impl.expression.VisitorAdapter; -import com.blazebit.persistence.impl.predicate.EqPredicate; -import com.blazebit.persistence.impl.predicate.InPredicate; -import com.blazebit.persistence.impl.predicate.IsEmptyPredicate; -import com.blazebit.persistence.impl.predicate.IsNullPredicate; -import com.blazebit.persistence.impl.predicate.MemberOfPredicate; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class JoinVisitor extends VisitorAdapter { - - private final JoinManager joinManager; - private boolean joinRequired; - private boolean joinWithObjectLeafAllowed = true; - private ClauseType fromClause; - - public JoinVisitor(JoinManager joinManager) { - this.joinManager = joinManager; - // By default we require joins - this.joinRequired = true; - } - - public ClauseType getFromClause() { - return fromClause; - } - - public void setFromClause(ClauseType fromClause) { - this.fromClause = fromClause; - } - - @Override - public void visit(PathExpression expression) { - joinManager.implicitJoin(expression, joinWithObjectLeafAllowed, fromClause, false, false, joinRequired); - } - - public boolean isJoinRequired() { - return joinRequired; - } - - public void setJoinRequired(boolean joinRequired) { - this.joinRequired = joinRequired; - } - - @Override - public void visit(FunctionExpression expression) { - // do not join outer expressions - if (!ExpressionUtils.isOuterFunction(expression)) { - super.visit(expression); - } - } - - // Added eager initialization of subqueries - @Override - public void visit(SubqueryExpression expression) { - // TODO: we have to pass the fromClause into the subquery so that joins, generated by OUTERs from the subquery don't get - // rendered if not needed - // TODO: this is ugly - ((AbstractCommonQueryBuilder) expression.getSubquery()).applyImplicitJoins(); - } - - public boolean isJoinWithObjectLeafAllowed() { - return joinWithObjectLeafAllowed; - } - - public void setJoinWithObjectLeafAllowed(boolean joinWithObjectLeafAllowed) { - this.joinWithObjectLeafAllowed = joinWithObjectLeafAllowed; - } - - @Override - public void visit(EqPredicate predicate) { - boolean original = joinRequired; - joinRequired = false; - predicate.getLeft().accept(this); - predicate.getRight().accept(this); - joinRequired = original; - } - - @Override - public void visit(IsNullPredicate predicate) { - boolean original = joinRequired; - joinRequired = false; - predicate.getExpression().accept(this); - joinRequired = original; - } - - @Override - public void visit(IsEmptyPredicate predicate) { - boolean original = joinRequired; - joinRequired = false; - predicate.getExpression().accept(this); - joinRequired = original; - } - - @Override - public void visit(MemberOfPredicate predicate) { - boolean original = joinRequired; - joinRequired = false; - predicate.getLeft().accept(this); - predicate.getRight().accept(this); - joinRequired = original; - } - - @Override - public void visit(InPredicate predicate) { - boolean original = joinRequired; - joinRequired = false; - predicate.getLeft().accept(this); - predicate.getRight().accept(this); - joinRequired = original; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.FunctionExpression; +import com.blazebit.persistence.impl.expression.PathExpression; +import com.blazebit.persistence.impl.expression.SubqueryExpression; +import com.blazebit.persistence.impl.expression.VisitorAdapter; +import com.blazebit.persistence.impl.predicate.EqPredicate; +import com.blazebit.persistence.impl.predicate.InPredicate; +import com.blazebit.persistence.impl.predicate.IsEmptyPredicate; +import com.blazebit.persistence.impl.predicate.IsNullPredicate; +import com.blazebit.persistence.impl.predicate.MemberOfPredicate; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class JoinVisitor extends VisitorAdapter { + + private final JoinManager joinManager; + private boolean joinRequired; + private boolean joinWithObjectLeafAllowed = true; + private ClauseType fromClause; + + public JoinVisitor(JoinManager joinManager) { + this.joinManager = joinManager; + // By default we require joins + this.joinRequired = true; + } + + public ClauseType getFromClause() { + return fromClause; + } + + public void setFromClause(ClauseType fromClause) { + this.fromClause = fromClause; + } + + @Override + public void visit(PathExpression expression) { + joinManager.implicitJoin(expression, joinWithObjectLeafAllowed, fromClause, false, false, joinRequired); + } + + public boolean isJoinRequired() { + return joinRequired; + } + + public void setJoinRequired(boolean joinRequired) { + this.joinRequired = joinRequired; + } + + @Override + public void visit(FunctionExpression expression) { + // do not join outer expressions + if (!ExpressionUtils.isOuterFunction(expression)) { + super.visit(expression); + } + } + + // Added eager initialization of subqueries + @Override + public void visit(SubqueryExpression expression) { + // TODO: we have to pass the fromClause into the subquery so that joins, generated by OUTERs from the subquery don't get + // rendered if not needed + // TODO: this is ugly + ((AbstractCommonQueryBuilder) expression.getSubquery()).applyImplicitJoins(); + } + + public boolean isJoinWithObjectLeafAllowed() { + return joinWithObjectLeafAllowed; + } + + public void setJoinWithObjectLeafAllowed(boolean joinWithObjectLeafAllowed) { + this.joinWithObjectLeafAllowed = joinWithObjectLeafAllowed; + } + + @Override + public void visit(EqPredicate predicate) { + boolean original = joinRequired; + joinRequired = false; + predicate.getLeft().accept(this); + predicate.getRight().accept(this); + joinRequired = original; + } + + @Override + public void visit(IsNullPredicate predicate) { + boolean original = joinRequired; + joinRequired = false; + predicate.getExpression().accept(this); + joinRequired = original; + } + + @Override + public void visit(IsEmptyPredicate predicate) { + boolean original = joinRequired; + joinRequired = false; + predicate.getExpression().accept(this); + joinRequired = original; + } + + @Override + public void visit(MemberOfPredicate predicate) { + boolean original = joinRequired; + joinRequired = false; + predicate.getLeft().accept(this); + predicate.getRight().accept(this); + joinRequired = original; + } + + @Override + public void visit(InPredicate predicate) { + boolean original = joinRequired; + joinRequired = false; + predicate.getLeft().accept(this); + predicate.getRight().accept(this); + joinRequired = original; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationCTECriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationCTECriteriaBuilderImpl.java index f7d6b9b82d..fa5651b5fe 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationCTECriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationCTECriteriaBuilderImpl.java @@ -1,63 +1,63 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.FinalSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.LeafOngoingSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.StartOngoingSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class LeafOngoingSetOperationCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, LeafOngoingSetOperationCTECriteriaBuilder, StartOngoingSetOperationCTECriteriaBuilder>> implements LeafOngoingSetOperationCTECriteriaBuilder { - - public LeafOngoingSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, T result, CTEBuilderListener listener, FinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder) { - super(mainQuery, cteName, clazz, result, listener, finalSetOperationBuilder); - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public FinalSetOperationCTECriteriaBuilder endSet() { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return (FinalSetOperationCTECriteriaBuilder) (FinalSetOperationCTECriteriaBuilder) finalSetOperationBuilder; - } - - @Override - protected BaseFinalSetOperationCTECriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - return createFinalSetOperationBuilder(operator, nested, nested); - } - - @Override - protected LeafOngoingSetOperationCTECriteriaBuilder createSetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return createLeaf(finalSetOperationBuilder); - } - - @Override - protected StartOngoingSetOperationCTECriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCTECriteriaBuilderImpl resultFinalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - LeafOngoingSetOperationCTECriteriaBuilder leafCb = createLeaf(resultFinalSetOperationBuilder); - return createOngoing(finalSetOperationBuilder, leafCb); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.FinalSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.LeafOngoingSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.StartOngoingSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class LeafOngoingSetOperationCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, LeafOngoingSetOperationCTECriteriaBuilder, StartOngoingSetOperationCTECriteriaBuilder>> implements LeafOngoingSetOperationCTECriteriaBuilder { + + public LeafOngoingSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, T result, CTEBuilderListener listener, FinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder) { + super(mainQuery, cteName, clazz, result, listener, finalSetOperationBuilder); + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public FinalSetOperationCTECriteriaBuilder endSet() { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return (FinalSetOperationCTECriteriaBuilder) (FinalSetOperationCTECriteriaBuilder) finalSetOperationBuilder; + } + + @Override + protected BaseFinalSetOperationCTECriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + return createFinalSetOperationBuilder(operator, nested, nested); + } + + @Override + protected LeafOngoingSetOperationCTECriteriaBuilder createSetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return createLeaf(finalSetOperationBuilder); + } + + @Override + protected StartOngoingSetOperationCTECriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCTECriteriaBuilderImpl resultFinalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + LeafOngoingSetOperationCTECriteriaBuilder leafCb = createLeaf(resultFinalSetOperationBuilder); + return createOngoing(finalSetOperationBuilder, leafCb); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationCriteriaBuilderImpl.java index 1f1e49cbcb..3fba9da36d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationCriteriaBuilderImpl.java @@ -1,63 +1,63 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.FinalSetOperationCriteriaBuilder; -import com.blazebit.persistence.LeafOngoingSetOperationCriteriaBuilder; -import com.blazebit.persistence.StartOngoingSetOperationCriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class LeafOngoingSetOperationCriteriaBuilderImpl extends AbstractCriteriaBuilder, LeafOngoingSetOperationCriteriaBuilder, StartOngoingSetOperationCriteriaBuilder>> implements LeafOngoingSetOperationCriteriaBuilder { - - public LeafOngoingSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, BuilderListener listener, FinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { - super(mainQuery, isMainQuery, clazz, null, listener, finalSetOperationBuilder); - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public FinalSetOperationCriteriaBuilder endSet() { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return (FinalSetOperationCriteriaBuilder) (FinalSetOperationCriteriaBuilder) finalSetOperationBuilder; - } - - @Override - protected BaseFinalSetOperationCriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - return createFinalSetOperationBuilder(operator, nested, nested); - } - - @Override - protected LeafOngoingSetOperationCriteriaBuilder createSetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return createLeaf(finalSetOperationBuilder); - } - - @Override - protected StartOngoingSetOperationCriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCriteriaBuilderImpl resultFinalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - LeafOngoingSetOperationCriteriaBuilder leafCb = createLeaf(resultFinalSetOperationBuilder); - return createOngoing(finalSetOperationBuilder, leafCb); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.FinalSetOperationCriteriaBuilder; +import com.blazebit.persistence.LeafOngoingSetOperationCriteriaBuilder; +import com.blazebit.persistence.StartOngoingSetOperationCriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class LeafOngoingSetOperationCriteriaBuilderImpl extends AbstractCriteriaBuilder, LeafOngoingSetOperationCriteriaBuilder, StartOngoingSetOperationCriteriaBuilder>> implements LeafOngoingSetOperationCriteriaBuilder { + + public LeafOngoingSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, BuilderListener listener, FinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { + super(mainQuery, isMainQuery, clazz, null, listener, finalSetOperationBuilder); + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public FinalSetOperationCriteriaBuilder endSet() { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return (FinalSetOperationCriteriaBuilder) (FinalSetOperationCriteriaBuilder) finalSetOperationBuilder; + } + + @Override + protected BaseFinalSetOperationCriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + return createFinalSetOperationBuilder(operator, nested, nested); + } + + @Override + protected LeafOngoingSetOperationCriteriaBuilder createSetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return createLeaf(finalSetOperationBuilder); + } + + @Override + protected StartOngoingSetOperationCriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCriteriaBuilderImpl resultFinalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + LeafOngoingSetOperationCriteriaBuilder leafCb = createLeaf(resultFinalSetOperationBuilder); + return createOngoing(finalSetOperationBuilder, leafCb); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationSubqueryBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationSubqueryBuilderImpl.java index d16d1120b5..5f6e97fa7a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationSubqueryBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/LeafOngoingSetOperationSubqueryBuilderImpl.java @@ -1,64 +1,64 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.FinalSetOperationSubqueryBuilder; -import com.blazebit.persistence.LeafOngoingSetOperationSubqueryBuilder; -import com.blazebit.persistence.StartOngoingSetOperationSubqueryBuilder; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class LeafOngoingSetOperationSubqueryBuilderImpl extends BaseSubqueryBuilderImpl, LeafOngoingSetOperationSubqueryBuilder, StartOngoingSetOperationSubqueryBuilder>> implements LeafOngoingSetOperationSubqueryBuilder { - - public LeafOngoingSetOperationSubqueryBuilderImpl(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager, ExpressionFactory expressionFactory, T result, SubqueryBuilderListener listener, FinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { - super(mainQuery, aliasManager, parentJoinManager, expressionFactory, result, listener, finalSetOperationBuilder); - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public FinalSetOperationSubqueryBuilder endSet() { - subListener.verifySubqueryBuilderEnded(); - listener.onBuilderEnded(this); - return (FinalSetOperationSubqueryBuilder) (FinalSetOperationSubqueryBuilder) finalSetOperationBuilder; - } - - @Override - protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - return createFinalSetOperationBuilder(operator, nested, nested); - } - - @Override - protected LeafOngoingSetOperationSubqueryBuilderImpl createSetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { - subListener.verifySubqueryBuilderEnded(); - listener.onBuilderEnded(this); - return createLeaf(finalSetOperationBuilder); - } - - @Override - protected StartOngoingSetOperationSubqueryBuilder> createSubquerySetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationSubqueryBuilderImpl resultFinalSetOperationBuilder) { - subListener.verifySubqueryBuilderEnded(); - listener.onBuilderEnded(this); - LeafOngoingSetOperationSubqueryBuilder leafCb = createLeaf(resultFinalSetOperationBuilder); - return createOngoing(finalSetOperationBuilder, leafCb); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.FinalSetOperationSubqueryBuilder; +import com.blazebit.persistence.LeafOngoingSetOperationSubqueryBuilder; +import com.blazebit.persistence.StartOngoingSetOperationSubqueryBuilder; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class LeafOngoingSetOperationSubqueryBuilderImpl extends BaseSubqueryBuilderImpl, LeafOngoingSetOperationSubqueryBuilder, StartOngoingSetOperationSubqueryBuilder>> implements LeafOngoingSetOperationSubqueryBuilder { + + public LeafOngoingSetOperationSubqueryBuilderImpl(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager, ExpressionFactory expressionFactory, T result, SubqueryBuilderListener listener, FinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { + super(mainQuery, aliasManager, parentJoinManager, expressionFactory, result, listener, finalSetOperationBuilder); + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public FinalSetOperationSubqueryBuilder endSet() { + subListener.verifySubqueryBuilderEnded(); + listener.onBuilderEnded(this); + return (FinalSetOperationSubqueryBuilder) (FinalSetOperationSubqueryBuilder) finalSetOperationBuilder; + } + + @Override + protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + return createFinalSetOperationBuilder(operator, nested, nested); + } + + @Override + protected LeafOngoingSetOperationSubqueryBuilderImpl createSetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { + subListener.verifySubqueryBuilderEnded(); + listener.onBuilderEnded(this); + return createLeaf(finalSetOperationBuilder); + } + + @Override + protected StartOngoingSetOperationSubqueryBuilder> createSubquerySetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationSubqueryBuilderImpl resultFinalSetOperationBuilder) { + subListener.verifySubqueryBuilderEnded(); + listener.onBuilderEnded(this); + LeafOngoingSetOperationSubqueryBuilder leafCb = createLeaf(resultFinalSetOperationBuilder); + return createOngoing(finalSetOperationBuilder, leafCb); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/OnClauseJoinNodeVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/OnClauseJoinNodeVisitor.java index 094854052b..a2e827daa5 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/OnClauseJoinNodeVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/OnClauseJoinNodeVisitor.java @@ -1,40 +1,40 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Moritz Becker - */ -public class OnClauseJoinNodeVisitor implements JoinNodeVisitor { - - private final Expression.Visitor visitor; - - public OnClauseJoinNodeVisitor(Expression.Visitor visitor) { - this.visitor = visitor; - } - - @Override - public void visit(JoinNode node) { - if (node.getOnPredicate() != null) { - node.getOnPredicate().accept(visitor); - } - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Moritz Becker + */ +public class OnClauseJoinNodeVisitor implements JoinNodeVisitor { + + private final Expression.Visitor visitor; + + public OnClauseJoinNodeVisitor(Expression.Visitor visitor) { + this.visitor = visitor; + } + + @Override + public void visit(JoinNode node) { + if (node.getOnPredicate() != null) { + node.getOnPredicate().accept(visitor); + } + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationCTECriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationCTECriteriaBuilderImpl.java index b9c6f6b064..f491c09c2d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationCTECriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationCTECriteriaBuilderImpl.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.OngoingFinalSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class OngoingFinalSetOperationCTECriteriaBuilderImpl extends BaseFinalSetOperationCTECriteriaBuilderImpl> implements OngoingFinalSetOperationCTECriteriaBuilder, CTEInfoBuilder { - - public OngoingFinalSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, Class clazz, T result, SetOperationType operator, boolean nested, CTEBuilderListener listener, FullSelectCTECriteriaBuilderImpl initiator) { - super(mainQuery, clazz, result, operator, nested, listener, initiator); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.OngoingFinalSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class OngoingFinalSetOperationCTECriteriaBuilderImpl extends BaseFinalSetOperationCTECriteriaBuilderImpl> implements OngoingFinalSetOperationCTECriteriaBuilder, CTEInfoBuilder { + + public OngoingFinalSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, Class clazz, T result, SetOperationType operator, boolean nested, CTEBuilderListener listener, FullSelectCTECriteriaBuilderImpl initiator) { + super(mainQuery, clazz, result, operator, nested, listener, initiator); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationCriteriaBuilderImpl.java index b90812914f..d06c7d8cac 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationCriteriaBuilderImpl.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.OngoingFinalSetOperationCriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class OngoingFinalSetOperationCriteriaBuilderImpl extends BaseFinalSetOperationCriteriaBuilderImpl> implements OngoingFinalSetOperationCriteriaBuilder { - - public OngoingFinalSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, SetOperationType operator, boolean nested, BuilderListener listener) { - super(mainQuery, isMainQuery, clazz, operator, nested, listener, null); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.OngoingFinalSetOperationCriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class OngoingFinalSetOperationCriteriaBuilderImpl extends BaseFinalSetOperationCriteriaBuilderImpl> implements OngoingFinalSetOperationCriteriaBuilder { + + public OngoingFinalSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, SetOperationType operator, boolean nested, BuilderListener listener) { + super(mainQuery, isMainQuery, clazz, operator, nested, listener, null); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationSubqueryBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationSubqueryBuilderImpl.java index fa264ff62c..e5da36a62a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationSubqueryBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingFinalSetOperationSubqueryBuilderImpl.java @@ -1,33 +1,33 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.OngoingFinalSetOperationSubqueryBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class OngoingFinalSetOperationSubqueryBuilderImpl extends BaseFinalSetOperationSubqueryBuilderImpl> implements OngoingFinalSetOperationSubqueryBuilder { - - public OngoingFinalSetOperationSubqueryBuilderImpl(MainQuery mainQuery, T result, SetOperationType operator, boolean nested, SubqueryBuilderListener listener, SubqueryBuilderImpl initiator) { - super(mainQuery, result, operator, nested, listener, initiator); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.OngoingFinalSetOperationSubqueryBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class OngoingFinalSetOperationSubqueryBuilderImpl extends BaseFinalSetOperationSubqueryBuilderImpl> implements OngoingFinalSetOperationSubqueryBuilder { + + public OngoingFinalSetOperationSubqueryBuilderImpl(MainQuery mainQuery, T result, SetOperationType operator, boolean nested, SubqueryBuilderListener listener, SubqueryBuilderImpl initiator) { + super(mainQuery, result, operator, nested, listener, initiator); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationCTECriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationCTECriteriaBuilderImpl.java index 15b4ea214b..a207bfde78 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationCTECriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationCTECriteriaBuilderImpl.java @@ -1,83 +1,83 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.OngoingFinalSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.OngoingSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.StartOngoingSetOperationCTECriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class OngoingSetOperationCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, OngoingSetOperationCTECriteriaBuilder, StartOngoingSetOperationCTECriteriaBuilder>> implements StartOngoingSetOperationCTECriteriaBuilder { - - private final Z endSetResult; - - public OngoingSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, T result, CTEBuilderListener listener, OngoingFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder, Z endSetResult) { - super(mainQuery, cteName, clazz, result, listener, finalSetOperationBuilder); - this.endSetResult = endSetResult; - } - - @Override - public OngoingSetOperationCTECriteriaBuilder from(Class clazz) { - return super.from(clazz); - } - - @Override - public OngoingSetOperationCTECriteriaBuilder from(Class clazz, String alias) { - return super.from(clazz, alias); - } - - @Override - public Z endSet() { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return endSetResult; - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public OngoingFinalSetOperationCTECriteriaBuilder endSetWith() { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return (OngoingFinalSetOperationCTECriteriaBuilder) (OngoingFinalSetOperationCTECriteriaBuilder) finalSetOperationBuilder; - } - - @Override - protected BaseFinalSetOperationCTECriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - return createFinalSetOperationBuilder(operator, nested, true); - } - - @Override - protected OngoingSetOperationCTECriteriaBuilder createSetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return createOngoing(finalSetOperationBuilder, endSetResult); - } - - @Override - protected StartOngoingSetOperationCTECriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCTECriteriaBuilderImpl resultFinalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - OngoingSetOperationCTECriteriaBuilder resultCb = createOngoing(resultFinalSetOperationBuilder, endSetResult); - return createOngoing(finalSetOperationBuilder, resultCb); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.OngoingFinalSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.OngoingSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.StartOngoingSetOperationCTECriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class OngoingSetOperationCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, OngoingSetOperationCTECriteriaBuilder, StartOngoingSetOperationCTECriteriaBuilder>> implements StartOngoingSetOperationCTECriteriaBuilder { + + private final Z endSetResult; + + public OngoingSetOperationCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, T result, CTEBuilderListener listener, OngoingFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder, Z endSetResult) { + super(mainQuery, cteName, clazz, result, listener, finalSetOperationBuilder); + this.endSetResult = endSetResult; + } + + @Override + public OngoingSetOperationCTECriteriaBuilder from(Class clazz) { + return super.from(clazz); + } + + @Override + public OngoingSetOperationCTECriteriaBuilder from(Class clazz, String alias) { + return super.from(clazz, alias); + } + + @Override + public Z endSet() { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return endSetResult; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public OngoingFinalSetOperationCTECriteriaBuilder endSetWith() { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return (OngoingFinalSetOperationCTECriteriaBuilder) (OngoingFinalSetOperationCTECriteriaBuilder) finalSetOperationBuilder; + } + + @Override + protected BaseFinalSetOperationCTECriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + return createFinalSetOperationBuilder(operator, nested, true); + } + + @Override + protected OngoingSetOperationCTECriteriaBuilder createSetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return createOngoing(finalSetOperationBuilder, endSetResult); + } + + @Override + protected StartOngoingSetOperationCTECriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCTECriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCTECriteriaBuilderImpl resultFinalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + OngoingSetOperationCTECriteriaBuilder resultCb = createOngoing(resultFinalSetOperationBuilder, endSetResult); + return createOngoing(finalSetOperationBuilder, resultCb); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationCriteriaBuilderImpl.java index 644444b51d..1d797cdc4a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationCriteriaBuilderImpl.java @@ -1,73 +1,73 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.OngoingFinalSetOperationCriteriaBuilder; -import com.blazebit.persistence.OngoingSetOperationCriteriaBuilder; -import com.blazebit.persistence.StartOngoingSetOperationCriteriaBuilder; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class OngoingSetOperationCriteriaBuilderImpl extends AbstractCriteriaBuilder, OngoingSetOperationCriteriaBuilder, StartOngoingSetOperationCriteriaBuilder>> implements StartOngoingSetOperationCriteriaBuilder { - - private final Z endSetResult; - - public OngoingSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, BuilderListener listener, OngoingFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, Z endSetResult) { - super(mainQuery, isMainQuery, clazz, null, listener, finalSetOperationBuilder); - this.endSetResult = endSetResult; - } - - @Override - public Z endSet() { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return endSetResult; - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public OngoingFinalSetOperationCriteriaBuilder endSetWith() { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return (OngoingFinalSetOperationCriteriaBuilder) (OngoingFinalSetOperationCriteriaBuilder) finalSetOperationBuilder; - } - - @Override - protected BaseFinalSetOperationCriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - return createFinalSetOperationBuilder(operator, nested, true); - } - - @Override - protected OngoingSetOperationCriteriaBuilder createSetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - return createOngoing(finalSetOperationBuilder, endSetResult); - } - - @Override - protected StartOngoingSetOperationCriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCriteriaBuilderImpl resultFinalSetOperationBuilder) { - subListener.verifyBuilderEnded(); - listener.onBuilderEnded(this); - OngoingSetOperationCriteriaBuilder resultCb = createOngoing(resultFinalSetOperationBuilder, endSetResult); - return createOngoing(finalSetOperationBuilder, resultCb); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.OngoingFinalSetOperationCriteriaBuilder; +import com.blazebit.persistence.OngoingSetOperationCriteriaBuilder; +import com.blazebit.persistence.StartOngoingSetOperationCriteriaBuilder; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class OngoingSetOperationCriteriaBuilderImpl extends AbstractCriteriaBuilder, OngoingSetOperationCriteriaBuilder, StartOngoingSetOperationCriteriaBuilder>> implements StartOngoingSetOperationCriteriaBuilder { + + private final Z endSetResult; + + public OngoingSetOperationCriteriaBuilderImpl(MainQuery mainQuery, boolean isMainQuery, Class clazz, BuilderListener listener, OngoingFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, Z endSetResult) { + super(mainQuery, isMainQuery, clazz, null, listener, finalSetOperationBuilder); + this.endSetResult = endSetResult; + } + + @Override + public Z endSet() { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return endSetResult; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public OngoingFinalSetOperationCriteriaBuilder endSetWith() { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return (OngoingFinalSetOperationCriteriaBuilder) (OngoingFinalSetOperationCriteriaBuilder) finalSetOperationBuilder; + } + + @Override + protected BaseFinalSetOperationCriteriaBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + return createFinalSetOperationBuilder(operator, nested, true); + } + + @Override + protected OngoingSetOperationCriteriaBuilder createSetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + return createOngoing(finalSetOperationBuilder, endSetResult); + } + + @Override + protected StartOngoingSetOperationCriteriaBuilder> createSubquerySetOperand(BaseFinalSetOperationCriteriaBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationCriteriaBuilderImpl resultFinalSetOperationBuilder) { + subListener.verifyBuilderEnded(); + listener.onBuilderEnded(this); + OngoingSetOperationCriteriaBuilder resultCb = createOngoing(resultFinalSetOperationBuilder, endSetResult); + return createOngoing(finalSetOperationBuilder, resultCb); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationSubqueryBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationSubqueryBuilderImpl.java index eb23809f4f..a8d4647cd3 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationSubqueryBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/OngoingSetOperationSubqueryBuilderImpl.java @@ -1,74 +1,74 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.OngoingFinalSetOperationSubqueryBuilder; -import com.blazebit.persistence.OngoingSetOperationSubqueryBuilder; -import com.blazebit.persistence.StartOngoingSetOperationSubqueryBuilder; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class OngoingSetOperationSubqueryBuilderImpl extends BaseSubqueryBuilderImpl, OngoingSetOperationSubqueryBuilder, StartOngoingSetOperationSubqueryBuilder>> implements StartOngoingSetOperationSubqueryBuilder { - - private final Z endSetResult; - - public OngoingSetOperationSubqueryBuilderImpl(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager, ExpressionFactory expressionFactory, T result, SubqueryBuilderListener listener, OngoingFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, Z endSetResult) { - super(mainQuery, aliasManager, parentJoinManager, expressionFactory, result, listener, finalSetOperationBuilder); - this.endSetResult = endSetResult; - } - - @Override - public Z endSet() { - subListener.verifySubqueryBuilderEnded(); - listener.onBuilderEnded(this); - return endSetResult; - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public OngoingFinalSetOperationSubqueryBuilder endSetWith() { - subListener.verifySubqueryBuilderEnded(); - listener.onBuilderEnded(this); - return (OngoingFinalSetOperationSubqueryBuilder) (OngoingFinalSetOperationSubqueryBuilder) finalSetOperationBuilder; - } - - @Override - protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - return createFinalSetOperationBuilder(operator, nested, true); - } - - @Override - protected OngoingSetOperationSubqueryBuilderImpl createSetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { - subListener.verifySubqueryBuilderEnded(); - listener.onBuilderEnded(this); - return createOngoing(finalSetOperationBuilder, endSetResult); - } - - @Override - protected StartOngoingSetOperationSubqueryBuilder> createSubquerySetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationSubqueryBuilderImpl resultFinalSetOperationBuilder) { - subListener.verifySubqueryBuilderEnded(); - listener.onBuilderEnded(this); - OngoingSetOperationSubqueryBuilder resultCb = createOngoing(resultFinalSetOperationBuilder, endSetResult); - return createOngoing(finalSetOperationBuilder, resultCb); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.OngoingFinalSetOperationSubqueryBuilder; +import com.blazebit.persistence.OngoingSetOperationSubqueryBuilder; +import com.blazebit.persistence.StartOngoingSetOperationSubqueryBuilder; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class OngoingSetOperationSubqueryBuilderImpl extends BaseSubqueryBuilderImpl, OngoingSetOperationSubqueryBuilder, StartOngoingSetOperationSubqueryBuilder>> implements StartOngoingSetOperationSubqueryBuilder { + + private final Z endSetResult; + + public OngoingSetOperationSubqueryBuilderImpl(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager, ExpressionFactory expressionFactory, T result, SubqueryBuilderListener listener, OngoingFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, Z endSetResult) { + super(mainQuery, aliasManager, parentJoinManager, expressionFactory, result, listener, finalSetOperationBuilder); + this.endSetResult = endSetResult; + } + + @Override + public Z endSet() { + subListener.verifySubqueryBuilderEnded(); + listener.onBuilderEnded(this); + return endSetResult; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public OngoingFinalSetOperationSubqueryBuilder endSetWith() { + subListener.verifySubqueryBuilderEnded(); + listener.onBuilderEnded(this); + return (OngoingFinalSetOperationSubqueryBuilder) (OngoingFinalSetOperationSubqueryBuilder) finalSetOperationBuilder; + } + + @Override + protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + return createFinalSetOperationBuilder(operator, nested, true); + } + + @Override + protected OngoingSetOperationSubqueryBuilderImpl createSetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { + subListener.verifySubqueryBuilderEnded(); + listener.onBuilderEnded(this); + return createOngoing(finalSetOperationBuilder, endSetResult); + } + + @Override + protected StartOngoingSetOperationSubqueryBuilder> createSubquerySetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationSubqueryBuilderImpl resultFinalSetOperationBuilder) { + subListener.verifySubqueryBuilderEnded(); + listener.onBuilderEnded(this); + OngoingSetOperationSubqueryBuilder resultCb = createOngoing(resultFinalSetOperationBuilder, endSetResult); + return createOngoing(finalSetOperationBuilder, resultCb); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/OrderByExpression.java b/core/impl/src/main/java/com/blazebit/persistence/impl/OrderByExpression.java index efc65305fe..bf6d4f6519 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/OrderByExpression.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/OrderByExpression.java @@ -1,95 +1,95 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public final class OrderByExpression { - - private final boolean ascending; - private final boolean nullFirst; - private final Expression expression; - private final boolean nullable; - private final boolean unique; - - public OrderByExpression(boolean ascending, boolean nullFirst, Expression expression, boolean nullable, boolean unique) { - this.ascending = ascending; - this.nullFirst = nullFirst; - this.expression = expression; - this.nullable = nullable; - this.unique = unique; - } - - public boolean isAscending() { - return ascending; - } - - public boolean isDescending() { - return !ascending; - } - - public boolean isNullFirst() { - return nullFirst; - } - - public Expression getExpression() { - return expression; - } - - public boolean isNullable() { - return nullable; - } - - public boolean isUnique() { - return unique; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 37 * hash + (this.ascending ? 1 : 0); - hash = 37 * hash + (this.nullFirst ? 1 : 0); - hash = 37 * hash + (this.expression != null ? this.expression.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final OrderByExpression other = (OrderByExpression) obj; - if (this.ascending != other.ascending) { - return false; - } - if (this.nullFirst != other.nullFirst) { - return false; - } - if (this.expression != other.expression && (this.expression == null || !this.expression.equals(other.expression))) { - return false; - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public final class OrderByExpression { + + private final boolean ascending; + private final boolean nullFirst; + private final Expression expression; + private final boolean nullable; + private final boolean unique; + + public OrderByExpression(boolean ascending, boolean nullFirst, Expression expression, boolean nullable, boolean unique) { + this.ascending = ascending; + this.nullFirst = nullFirst; + this.expression = expression; + this.nullable = nullable; + this.unique = unique; + } + + public boolean isAscending() { + return ascending; + } + + public boolean isDescending() { + return !ascending; + } + + public boolean isNullFirst() { + return nullFirst; + } + + public Expression getExpression() { + return expression; + } + + public boolean isNullable() { + return nullable; + } + + public boolean isUnique() { + return unique; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 37 * hash + (this.ascending ? 1 : 0); + hash = 37 * hash + (this.nullFirst ? 1 : 0); + hash = 37 * hash + (this.expression != null ? this.expression.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final OrderByExpression other = (OrderByExpression) obj; + if (this.ascending != other.ascending) { + return false; + } + if (this.nullFirst != other.nullFirst) { + return false; + } + if (this.expression != other.expression && (this.expression == null || !this.expression.equals(other.expression))) { + return false; + } + return true; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/PagedListImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/PagedListImpl.java index 2f89a370c1..22e46f4573 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/PagedListImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/PagedListImpl.java @@ -1,96 +1,96 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.ArrayList; -import java.util.Collection; - -import com.blazebit.persistence.KeysetPage; -import com.blazebit.persistence.PagedList; - -/** - * - * @param the type of elements in this list - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class PagedListImpl extends ArrayList implements PagedList { - - private static final long serialVersionUID = 1L; - - private final KeysetPage keyset; - private final long totalSize; - private final int page; - private final int totalPages; - private final int firstResult; - private final int maxResults; - - public PagedListImpl(KeysetPage keyset, long totalSize, int firstResult, int maxResults) { - this.keyset = keyset; - this.totalSize = totalSize; - this.page = (int) Math.floor((firstResult == -1 ? 0 : firstResult) * 1d / maxResults) + 1; - this.totalPages = (int) Math.ceil(totalSize * 1d / maxResults); - this.firstResult = firstResult; - this.maxResults = maxResults; - } - - PagedListImpl(Collection collection, KeysetPage keyset, long totalSize, int firstResult, int maxResults) { - super(collection); - this.keyset = keyset; - this.totalSize = totalSize; - this.page = (int) Math.floor((firstResult == -1 ? 0 : firstResult) * 1d / maxResults) + 1; - this.totalPages = (int) Math.ceil(totalSize * 1d / maxResults); - this.firstResult = firstResult; - this.maxResults = maxResults; - } - - @Override - public int getSize() { - return size(); - } - - @Override - public long getTotalSize() { - return totalSize; - } - - @Override - public int getPage() { - return page; - } - - @Override - public int getTotalPages() { - return totalPages; - } - - @Override - public int getFirstResult() { - return firstResult; - } - - @Override - public int getMaxResults() { - return maxResults; - } - - @Override - public KeysetPage getKeysetPage() { - return keyset; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.ArrayList; +import java.util.Collection; + +import com.blazebit.persistence.KeysetPage; +import com.blazebit.persistence.PagedList; + +/** + * + * @param the type of elements in this list + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class PagedListImpl extends ArrayList implements PagedList { + + private static final long serialVersionUID = 1L; + + private final KeysetPage keyset; + private final long totalSize; + private final int page; + private final int totalPages; + private final int firstResult; + private final int maxResults; + + public PagedListImpl(KeysetPage keyset, long totalSize, int firstResult, int maxResults) { + this.keyset = keyset; + this.totalSize = totalSize; + this.page = (int) Math.floor((firstResult == -1 ? 0 : firstResult) * 1d / maxResults) + 1; + this.totalPages = (int) Math.ceil(totalSize * 1d / maxResults); + this.firstResult = firstResult; + this.maxResults = maxResults; + } + + PagedListImpl(Collection collection, KeysetPage keyset, long totalSize, int firstResult, int maxResults) { + super(collection); + this.keyset = keyset; + this.totalSize = totalSize; + this.page = (int) Math.floor((firstResult == -1 ? 0 : firstResult) * 1d / maxResults) + 1; + this.totalPages = (int) Math.ceil(totalSize * 1d / maxResults); + this.firstResult = firstResult; + this.maxResults = maxResults; + } + + @Override + public int getSize() { + return size(); + } + + @Override + public long getTotalSize() { + return totalSize; + } + + @Override + public int getPage() { + return page; + } + + @Override + public int getTotalPages() { + return totalPages; + } + + @Override + public int getFirstResult() { + return firstResult; + } + + @Override + public int getMaxResults() { + return maxResults; + } + + @Override + public KeysetPage getKeysetPage() { + return keyset; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ParameterRegistrationVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ParameterRegistrationVisitor.java index 629e9f9c20..155433b4ca 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ParameterRegistrationVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ParameterRegistrationVisitor.java @@ -1,43 +1,43 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.ParameterExpression; -import com.blazebit.persistence.impl.expression.VisitorAdapter; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class ParameterRegistrationVisitor extends VisitorAdapter { - - private final ParameterManager parameterManager; - - public ParameterRegistrationVisitor(ParameterManager parameterManager) { - this.parameterManager = parameterManager; - } - - @Override - public void visit(ParameterExpression expression) { - // Value was not set so we only have an unsatisfied parameter name which we register - if (AbstractFullQueryBuilder.idParamName.equals(expression.getName())) { - throw new IllegalArgumentException("The parameter name '" + expression.getName() + "' is reserved - use a different name"); - } else { - parameterManager.registerParameterName(expression.getName()); - } - } -}; +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.ParameterExpression; +import com.blazebit.persistence.impl.expression.VisitorAdapter; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class ParameterRegistrationVisitor extends VisitorAdapter { + + private final ParameterManager parameterManager; + + public ParameterRegistrationVisitor(ParameterManager parameterManager) { + this.parameterManager = parameterManager; + } + + @Override + public void visit(ParameterExpression expression) { + // Value was not set so we only have an unsatisfied parameter name which we register + if (AbstractFullQueryBuilder.idParamName.equals(expression.getName())) { + throw new IllegalArgumentException("The parameter name '" + expression.getName() + "' is reserved - use a different name"); + } else { + parameterManager.registerParameterName(expression.getName()); + } + } +}; diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/PredicateAndSubqueryBuilderEndedListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/PredicateAndSubqueryBuilderEndedListener.java index 4a2c9e59f4..17fa36847f 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/PredicateAndSubqueryBuilderEndedListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/PredicateAndSubqueryBuilderEndedListener.java @@ -1,66 +1,66 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.SubqueryInitiator; -import com.blazebit.persistence.impl.builder.predicate.PredicateBuilderEndedListener; -import com.blazebit.persistence.impl.builder.predicate.PredicateBuilderEndedListenerImpl; -import com.blazebit.persistence.impl.predicate.PredicateBuilder; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class PredicateAndSubqueryBuilderEndedListener implements PredicateBuilderEndedListener, SubqueryBuilderListener { - - private final PredicateBuilderEndedListenerImpl predicateBuilderListener = new PredicateBuilderEndedListenerImpl(); - private final SubqueryBuilderListenerImpl subqueryBuilderListener = new SubqueryBuilderListenerImpl(); - - @Override - public void onBuilderEnded(PredicateBuilder o) { - predicateBuilderListener.onBuilderEnded(o); - } - - @Override - public void onReplaceBuilder(SubqueryInternalBuilder oldBuilder, SubqueryInternalBuilder newBuilder) { - subqueryBuilderListener.onReplaceBuilder(oldBuilder, newBuilder); - } - - @Override - public void onBuilderEnded(SubqueryInternalBuilder builder) { - subqueryBuilderListener.onBuilderEnded(builder); - } - - @Override - public void onBuilderStarted(SubqueryInternalBuilder builder) { - subqueryBuilderListener.onBuilderStarted(builder); - } - - @Override - public void onInitiatorStarted(SubqueryInitiator initiator) { - subqueryBuilderListener.onInitiatorStarted(initiator); - } - - protected void verifyBuilderEnded() { - predicateBuilderListener.verifyBuilderEnded(); - subqueryBuilderListener.verifySubqueryBuilderEnded(); - } - - protected X startBuilder(X builder) { - return predicateBuilderListener.startBuilder(builder); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.SubqueryInitiator; +import com.blazebit.persistence.impl.builder.predicate.PredicateBuilderEndedListener; +import com.blazebit.persistence.impl.builder.predicate.PredicateBuilderEndedListenerImpl; +import com.blazebit.persistence.impl.predicate.PredicateBuilder; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class PredicateAndSubqueryBuilderEndedListener implements PredicateBuilderEndedListener, SubqueryBuilderListener { + + private final PredicateBuilderEndedListenerImpl predicateBuilderListener = new PredicateBuilderEndedListenerImpl(); + private final SubqueryBuilderListenerImpl subqueryBuilderListener = new SubqueryBuilderListenerImpl(); + + @Override + public void onBuilderEnded(PredicateBuilder o) { + predicateBuilderListener.onBuilderEnded(o); + } + + @Override + public void onReplaceBuilder(SubqueryInternalBuilder oldBuilder, SubqueryInternalBuilder newBuilder) { + subqueryBuilderListener.onReplaceBuilder(oldBuilder, newBuilder); + } + + @Override + public void onBuilderEnded(SubqueryInternalBuilder builder) { + subqueryBuilderListener.onBuilderEnded(builder); + } + + @Override + public void onBuilderStarted(SubqueryInternalBuilder builder) { + subqueryBuilderListener.onBuilderStarted(builder); + } + + @Override + public void onInitiatorStarted(SubqueryInitiator initiator) { + subqueryBuilderListener.onInitiatorStarted(initiator); + } + + protected void verifyBuilderEnded() { + predicateBuilderListener.verifyBuilderEnded(); + subqueryBuilderListener.verifySubqueryBuilderEnded(); + } + + protected X startBuilder(X builder) { + return predicateBuilderListener.startBuilder(builder); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/QueryToTypedQueryAdapter.java b/core/impl/src/main/java/com/blazebit/persistence/impl/QueryToTypedQueryAdapter.java index 030b80fbfa..e24af1dc0b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/QueryToTypedQueryAdapter.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/QueryToTypedQueryAdapter.java @@ -1,193 +1,193 @@ -package com.blazebit.persistence.impl; - -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.persistence.FlushModeType; -import javax.persistence.LockModeType; -import javax.persistence.Parameter; -import javax.persistence.Query; -import javax.persistence.TemporalType; -import javax.persistence.TypedQuery; - -public class QueryToTypedQueryAdapter implements TypedQuery { - - private final Query delegate; - - public QueryToTypedQueryAdapter(Query delegate) { - this.delegate = delegate; - } - - private TypedQuery wrapOrReturn(Query q) { - if (q == delegate) { - return this; - } - - return new QueryToTypedQueryAdapter(q); - } - - @Override - @SuppressWarnings("unchecked") - public List getResultList() { - return delegate.getResultList(); - } - - @Override - @SuppressWarnings("unchecked") - public X getSingleResult() { - return (X) delegate.getSingleResult(); - } - - @Override - public int executeUpdate() { - return delegate.executeUpdate(); - } - - @Override - public TypedQuery setMaxResults(int maxResult) { - return wrapOrReturn(delegate.setMaxResults(maxResult)); - } - - @Override - public int getMaxResults() { - return delegate.getMaxResults(); - } - - @Override - public TypedQuery setFirstResult(int startPosition) { - return wrapOrReturn(delegate.setFirstResult(startPosition)); - } - - @Override - public int getFirstResult() { - return delegate.getFirstResult(); - } - - @Override - public TypedQuery setHint(String hintName, Object value) { - return wrapOrReturn(delegate.setHint(hintName, value)); - } - - @Override - public Map getHints() { - return delegate.getHints(); - } - - @Override - public TypedQuery setParameter(Parameter param, T value) { - return wrapOrReturn(delegate.setParameter(param, value)); - } - - @Override - public TypedQuery setParameter(Parameter param, Calendar value, TemporalType temporalType) { - return wrapOrReturn(delegate.setParameter(param, value, temporalType)); - } - - @Override - public TypedQuery setParameter(Parameter param, Date value, TemporalType temporalType) { - return wrapOrReturn(delegate.setParameter(param, value, temporalType)); - } - - @Override - public TypedQuery setParameter(String name, Object value) { - return wrapOrReturn(delegate.setParameter(name, value)); - } - - @Override - public TypedQuery setParameter(String name, Calendar value, TemporalType temporalType) { - return wrapOrReturn(delegate.setParameter(name, value, temporalType)); - } - - @Override - public TypedQuery setParameter(String name, Date value, TemporalType temporalType) { - return wrapOrReturn(delegate.setParameter(name, value, temporalType)); - } - - @Override - public TypedQuery setParameter(int position, Object value) { - return wrapOrReturn(delegate.setParameter(position, value)); - } - - @Override - public TypedQuery setParameter(int position, Calendar value, TemporalType temporalType) { - return wrapOrReturn(delegate.setParameter(position, value, temporalType)); - } - - @Override - public TypedQuery setParameter(int position, Date value, TemporalType temporalType) { - return wrapOrReturn(delegate.setParameter(position, value, temporalType)); - } - - @Override - public Set> getParameters() { - return delegate.getParameters(); - } - - @Override - public Parameter getParameter(String name) { - return delegate.getParameter(name); - } - - @Override - public Parameter getParameter(String name, Class type) { - return delegate.getParameter(name, type); - } - - @Override - public Parameter getParameter(int position) { - return delegate.getParameter(position); - } - - @Override - public Parameter getParameter(int position, Class type) { - return delegate.getParameter(position, type); - } - - @Override - public boolean isBound(Parameter param) { - return delegate.isBound(param); - } - - @Override - public T getParameterValue(Parameter param) { - return delegate.getParameterValue(param); - } - - @Override - public Object getParameterValue(String name) { - return delegate.getParameterValue(name); - } - - @Override - public Object getParameterValue(int position) { - return delegate.getParameterValue(position); - } - - @Override - public TypedQuery setFlushMode(FlushModeType flushMode) { - return wrapOrReturn(delegate.setFlushMode(flushMode)); - } - - @Override - public FlushModeType getFlushMode() { - return delegate.getFlushMode(); - } - - @Override - public TypedQuery setLockMode(LockModeType lockMode) { - return wrapOrReturn(delegate.setLockMode(lockMode)); - } - - @Override - public LockModeType getLockMode() { - return delegate.getLockMode(); - } - - @Override - public T unwrap(Class cls) { - return delegate.unwrap(cls); - } -} +package com.blazebit.persistence.impl; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.persistence.FlushModeType; +import javax.persistence.LockModeType; +import javax.persistence.Parameter; +import javax.persistence.Query; +import javax.persistence.TemporalType; +import javax.persistence.TypedQuery; + +public class QueryToTypedQueryAdapter implements TypedQuery { + + private final Query delegate; + + public QueryToTypedQueryAdapter(Query delegate) { + this.delegate = delegate; + } + + private TypedQuery wrapOrReturn(Query q) { + if (q == delegate) { + return this; + } + + return new QueryToTypedQueryAdapter(q); + } + + @Override + @SuppressWarnings("unchecked") + public List getResultList() { + return delegate.getResultList(); + } + + @Override + @SuppressWarnings("unchecked") + public X getSingleResult() { + return (X) delegate.getSingleResult(); + } + + @Override + public int executeUpdate() { + return delegate.executeUpdate(); + } + + @Override + public TypedQuery setMaxResults(int maxResult) { + return wrapOrReturn(delegate.setMaxResults(maxResult)); + } + + @Override + public int getMaxResults() { + return delegate.getMaxResults(); + } + + @Override + public TypedQuery setFirstResult(int startPosition) { + return wrapOrReturn(delegate.setFirstResult(startPosition)); + } + + @Override + public int getFirstResult() { + return delegate.getFirstResult(); + } + + @Override + public TypedQuery setHint(String hintName, Object value) { + return wrapOrReturn(delegate.setHint(hintName, value)); + } + + @Override + public Map getHints() { + return delegate.getHints(); + } + + @Override + public TypedQuery setParameter(Parameter param, T value) { + return wrapOrReturn(delegate.setParameter(param, value)); + } + + @Override + public TypedQuery setParameter(Parameter param, Calendar value, TemporalType temporalType) { + return wrapOrReturn(delegate.setParameter(param, value, temporalType)); + } + + @Override + public TypedQuery setParameter(Parameter param, Date value, TemporalType temporalType) { + return wrapOrReturn(delegate.setParameter(param, value, temporalType)); + } + + @Override + public TypedQuery setParameter(String name, Object value) { + return wrapOrReturn(delegate.setParameter(name, value)); + } + + @Override + public TypedQuery setParameter(String name, Calendar value, TemporalType temporalType) { + return wrapOrReturn(delegate.setParameter(name, value, temporalType)); + } + + @Override + public TypedQuery setParameter(String name, Date value, TemporalType temporalType) { + return wrapOrReturn(delegate.setParameter(name, value, temporalType)); + } + + @Override + public TypedQuery setParameter(int position, Object value) { + return wrapOrReturn(delegate.setParameter(position, value)); + } + + @Override + public TypedQuery setParameter(int position, Calendar value, TemporalType temporalType) { + return wrapOrReturn(delegate.setParameter(position, value, temporalType)); + } + + @Override + public TypedQuery setParameter(int position, Date value, TemporalType temporalType) { + return wrapOrReturn(delegate.setParameter(position, value, temporalType)); + } + + @Override + public Set> getParameters() { + return delegate.getParameters(); + } + + @Override + public Parameter getParameter(String name) { + return delegate.getParameter(name); + } + + @Override + public Parameter getParameter(String name, Class type) { + return delegate.getParameter(name, type); + } + + @Override + public Parameter getParameter(int position) { + return delegate.getParameter(position); + } + + @Override + public Parameter getParameter(int position, Class type) { + return delegate.getParameter(position, type); + } + + @Override + public boolean isBound(Parameter param) { + return delegate.isBound(param); + } + + @Override + public T getParameterValue(Parameter param) { + return delegate.getParameterValue(param); + } + + @Override + public Object getParameterValue(String name) { + return delegate.getParameterValue(name); + } + + @Override + public Object getParameterValue(int position) { + return delegate.getParameterValue(position); + } + + @Override + public TypedQuery setFlushMode(FlushModeType flushMode) { + return wrapOrReturn(delegate.setFlushMode(flushMode)); + } + + @Override + public FlushModeType getFlushMode() { + return delegate.getFlushMode(); + } + + @Override + public TypedQuery setLockMode(LockModeType lockMode) { + return wrapOrReturn(delegate.setLockMode(lockMode)); + } + + @Override + public LockModeType getLockMode() { + return delegate.getLockMode(); + } + + @Override + public T unwrap(Class cls) { + return delegate.unwrap(cls); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/RecursiveCTECriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/RecursiveCTECriteriaBuilderImpl.java index 2551fc7344..0b7c257d5d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/RecursiveCTECriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/RecursiveCTECriteriaBuilderImpl.java @@ -1,69 +1,69 @@ -package com.blazebit.persistence.impl; - -import java.util.List; - -import com.blazebit.persistence.SelectCTECriteriaBuilder; -import com.blazebit.persistence.SelectRecursiveCTECriteriaBuilder; - -public class RecursiveCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, SelectCTECriteriaBuilder, Void> implements SelectRecursiveCTECriteriaBuilder, CTEBuilderListener { - - protected final Class clazz; - protected boolean done; - protected boolean unionAll; - protected SelectCTECriteriaBuilderImpl recursiveCteBuilder; - - public RecursiveCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, Y result, final CTEBuilderListener listener) { - super(mainQuery, cteName, clazz, result, listener, null); - this.clazz = clazz; - } - - @Override - public SelectCTECriteriaBuilderImpl union() { - verifyBuilderEnded(); - unionAll = false; - recursiveCteBuilder = new SelectCTECriteriaBuilderImpl(mainQuery, cteName, clazz, result, this); - return recursiveCteBuilder; - } - - @Override - public SelectCTECriteriaBuilderImpl unionAll() { - verifyBuilderEnded(); - unionAll = true; - recursiveCteBuilder = new SelectCTECriteriaBuilderImpl(mainQuery, cteName, clazz, result, this); - return recursiveCteBuilder; - } - - @Override - public void onReplaceBuilder(CTEInfoBuilder oldBuilder, CTEInfoBuilder newBuilder) { - // Don't care about that - } - - @Override - public void onBuilderStarted(CTEInfoBuilder builder) { - // Don't care about that - } - - @Override - public void onBuilderEnded(CTEInfoBuilder builder) { - done = true; - listener.onBuilderEnded(this); - } - - public void verifyBuilderEnded() { - if (recursiveCteBuilder != null && !done) { - throw new BuilderChainingException("A builder was not ended properly."); - } - } - - @Override - public CTEInfo createCTEInfo() { - verifyBuilderEnded(); - List attributes = prepareAndGetAttributes(); - - // As a side effect, this will reorder selects according to attribute order - recursiveCteBuilder.createCTEInfo(); - CTEInfo info = new CTEInfo(cteName, cteType, attributes, true, unionAll, this, recursiveCteBuilder); - return info; - } - -} +package com.blazebit.persistence.impl; + +import java.util.List; + +import com.blazebit.persistence.SelectCTECriteriaBuilder; +import com.blazebit.persistence.SelectRecursiveCTECriteriaBuilder; + +public class RecursiveCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, SelectCTECriteriaBuilder, Void> implements SelectRecursiveCTECriteriaBuilder, CTEBuilderListener { + + protected final Class clazz; + protected boolean done; + protected boolean unionAll; + protected SelectCTECriteriaBuilderImpl recursiveCteBuilder; + + public RecursiveCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, Y result, final CTEBuilderListener listener) { + super(mainQuery, cteName, clazz, result, listener, null); + this.clazz = clazz; + } + + @Override + public SelectCTECriteriaBuilderImpl union() { + verifyBuilderEnded(); + unionAll = false; + recursiveCteBuilder = new SelectCTECriteriaBuilderImpl(mainQuery, cteName, clazz, result, this); + return recursiveCteBuilder; + } + + @Override + public SelectCTECriteriaBuilderImpl unionAll() { + verifyBuilderEnded(); + unionAll = true; + recursiveCteBuilder = new SelectCTECriteriaBuilderImpl(mainQuery, cteName, clazz, result, this); + return recursiveCteBuilder; + } + + @Override + public void onReplaceBuilder(CTEInfoBuilder oldBuilder, CTEInfoBuilder newBuilder) { + // Don't care about that + } + + @Override + public void onBuilderStarted(CTEInfoBuilder builder) { + // Don't care about that + } + + @Override + public void onBuilderEnded(CTEInfoBuilder builder) { + done = true; + listener.onBuilderEnded(this); + } + + public void verifyBuilderEnded() { + if (recursiveCteBuilder != null && !done) { + throw new BuilderChainingException("A builder was not ended properly."); + } + } + + @Override + public CTEInfo createCTEInfo() { + verifyBuilderEnded(); + List attributes = prepareAndGetAttributes(); + + // As a side effect, this will reorder selects according to attribute order + recursiveCteBuilder.createCTEInfo(); + CTEInfo info = new CTEInfo(cteName, cteType, attributes, true, unionAll, this, recursiveCteBuilder); + return info; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ResultJoinNodeVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ResultJoinNodeVisitor.java index df8b4cf8c0..d6ece568e8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ResultJoinNodeVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ResultJoinNodeVisitor.java @@ -1,27 +1,27 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -/** - * - * @author Christian Beikov - * @since 1.0.5 - */ -public interface ResultJoinNodeVisitor { - - public T visit(JoinNode node); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +/** + * + * @author Christian Beikov + * @since 1.0.5 + */ +public interface ResultJoinNodeVisitor { + + public T visit(JoinNode node); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningDeleteCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningDeleteCriteriaBuilderImpl.java index 618dbc3f84..e3c86c0a76 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningDeleteCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningDeleteCriteriaBuilderImpl.java @@ -1,38 +1,38 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.ReturningDeleteCriteriaBuilder; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class ReturningDeleteCriteriaBuilderImpl extends BaseDeleteCriteriaBuilderImpl, Y> implements ReturningDeleteCriteriaBuilder { - - public ReturningDeleteCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String alias, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { - super(mainQuery, false, clazz, alias, cteName, cteClass, result, listener); - } - - @Override - protected void getCteQueryString1(StringBuilder sbSelectFrom) { - super.getCteQueryString1(sbSelectFrom); - applyJpaReturning(sbSelectFrom); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.ReturningDeleteCriteriaBuilder; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class ReturningDeleteCriteriaBuilderImpl extends BaseDeleteCriteriaBuilderImpl, Y> implements ReturningDeleteCriteriaBuilder { + + public ReturningDeleteCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String alias, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { + super(mainQuery, false, clazz, alias, cteName, cteClass, result, listener); + } + + @Override + protected void getCteQueryString1(StringBuilder sbSelectFrom) { + super.getCteQueryString1(sbSelectFrom); + applyJpaReturning(sbSelectFrom); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningInsertCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningInsertCriteriaBuilderImpl.java index 9625f00f64..61fb33ded1 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningInsertCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningInsertCriteriaBuilderImpl.java @@ -1,38 +1,38 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.ReturningInsertCriteriaBuilder; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class ReturningInsertCriteriaBuilderImpl extends BaseInsertCriteriaBuilderImpl, Y> implements ReturningInsertCriteriaBuilder { - - public ReturningInsertCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { - super(mainQuery, false, clazz, cteName, cteClass, result, listener); - } - - @Override - protected void getCteQueryString1(StringBuilder sbSelectFrom) { - super.getCteQueryString1(sbSelectFrom); - applyJpaReturning(sbSelectFrom); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.ReturningInsertCriteriaBuilder; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class ReturningInsertCriteriaBuilderImpl extends BaseInsertCriteriaBuilderImpl, Y> implements ReturningInsertCriteriaBuilder { + + public ReturningInsertCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { + super(mainQuery, false, clazz, cteName, cteClass, result, listener); + } + + @Override + protected void getCteQueryString1(StringBuilder sbSelectFrom) { + super.getCteQueryString1(sbSelectFrom); + applyJpaReturning(sbSelectFrom); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningModificationCriteraBuilderFactoryImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningModificationCriteraBuilderFactoryImpl.java index 293ac63069..e616699795 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningModificationCriteraBuilderFactoryImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningModificationCriteraBuilderFactoryImpl.java @@ -1,76 +1,76 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.ReturningDeleteCriteriaBuilder; -import com.blazebit.persistence.ReturningInsertCriteriaBuilder; -import com.blazebit.persistence.ReturningModificationCriteriaBuilderFactory; -import com.blazebit.persistence.ReturningUpdateCriteriaBuilder; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.1.0 - */ -public class ReturningModificationCriteraBuilderFactoryImpl implements ReturningModificationCriteriaBuilderFactory { - - private final MainQuery mainQuery; - private final String cteName; - private final Class cteClass; - private final X result; - private final CTEBuilderListener listener; - - ReturningModificationCriteraBuilderFactoryImpl(MainQuery mainQuery, String cteName, Class cteClass, X result, final CTEBuilderListener listener) { - this.mainQuery = mainQuery; - this.cteName = cteName; - this.cteClass = cteClass; - this.result = result; - this.listener = listener; - } - - @Override - public ReturningDeleteCriteriaBuilder delete(Class deleteClass) { - return delete(deleteClass, null); - } - - @Override - public ReturningDeleteCriteriaBuilder delete(Class deleteClass, String alias) { - ReturningDeleteCriteriaBuilderImpl cb = new ReturningDeleteCriteriaBuilderImpl(mainQuery, deleteClass, alias, cteName, cteClass, result, listener); - listener.onBuilderStarted(cb); - return cb; - } - - @Override - public ReturningUpdateCriteriaBuilder update(Class updateClass) { - return update(updateClass, null); - } - - @Override - public ReturningUpdateCriteriaBuilder update(Class updateClass, String alias) { - ReturningUpdateCriteriaBuilderImpl cb = new ReturningUpdateCriteriaBuilderImpl(mainQuery, updateClass, alias, cteName, cteClass, result, listener); - listener.onBuilderStarted(cb); - return cb; - } - - @Override - public ReturningInsertCriteriaBuilder insert(Class insertClass) { - ReturningInsertCriteriaBuilderImpl cb = new ReturningInsertCriteriaBuilderImpl(mainQuery, insertClass, cteName, cteClass, result, listener); - listener.onBuilderStarted(cb); - return cb; - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.ReturningDeleteCriteriaBuilder; +import com.blazebit.persistence.ReturningInsertCriteriaBuilder; +import com.blazebit.persistence.ReturningModificationCriteriaBuilderFactory; +import com.blazebit.persistence.ReturningUpdateCriteriaBuilder; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.1.0 + */ +public class ReturningModificationCriteraBuilderFactoryImpl implements ReturningModificationCriteriaBuilderFactory { + + private final MainQuery mainQuery; + private final String cteName; + private final Class cteClass; + private final X result; + private final CTEBuilderListener listener; + + ReturningModificationCriteraBuilderFactoryImpl(MainQuery mainQuery, String cteName, Class cteClass, X result, final CTEBuilderListener listener) { + this.mainQuery = mainQuery; + this.cteName = cteName; + this.cteClass = cteClass; + this.result = result; + this.listener = listener; + } + + @Override + public ReturningDeleteCriteriaBuilder delete(Class deleteClass) { + return delete(deleteClass, null); + } + + @Override + public ReturningDeleteCriteriaBuilder delete(Class deleteClass, String alias) { + ReturningDeleteCriteriaBuilderImpl cb = new ReturningDeleteCriteriaBuilderImpl(mainQuery, deleteClass, alias, cteName, cteClass, result, listener); + listener.onBuilderStarted(cb); + return cb; + } + + @Override + public ReturningUpdateCriteriaBuilder update(Class updateClass) { + return update(updateClass, null); + } + + @Override + public ReturningUpdateCriteriaBuilder update(Class updateClass, String alias) { + ReturningUpdateCriteriaBuilderImpl cb = new ReturningUpdateCriteriaBuilderImpl(mainQuery, updateClass, alias, cteName, cteClass, result, listener); + listener.onBuilderStarted(cb); + return cb; + } + + @Override + public ReturningInsertCriteriaBuilder insert(Class insertClass) { + ReturningInsertCriteriaBuilderImpl cb = new ReturningInsertCriteriaBuilderImpl(mainQuery, insertClass, cteName, cteClass, result, listener); + listener.onBuilderStarted(cb); + return cb; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningUpdateCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningUpdateCriteriaBuilderImpl.java index fd4e9870cd..8066f60262 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningUpdateCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ReturningUpdateCriteriaBuilderImpl.java @@ -1,38 +1,38 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.ReturningUpdateCriteriaBuilder; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class ReturningUpdateCriteriaBuilderImpl extends BaseUpdateCriteriaBuilderImpl, Y> implements ReturningUpdateCriteriaBuilder { - - public ReturningUpdateCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String alias, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { - super(mainQuery, false, clazz, alias, cteName, cteClass, result, listener); - } - - @Override - protected void getCteQueryString1(StringBuilder sbSelectFrom) { - super.getCteQueryString1(sbSelectFrom); - applyJpaReturning(sbSelectFrom); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.ReturningUpdateCriteriaBuilder; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class ReturningUpdateCriteriaBuilderImpl extends BaseUpdateCriteriaBuilderImpl, Y> implements ReturningUpdateCriteriaBuilder { + + public ReturningUpdateCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String alias, String cteName, Class cteClass, Y result, CTEBuilderListener listener) { + super(mainQuery, false, clazz, alias, cteName, cteClass, result, listener); + } + + @Override + protected void getCteQueryString1(StringBuilder sbSelectFrom) { + super.getCteQueryString1(sbSelectFrom); + applyJpaReturning(sbSelectFrom); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectCTECriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectCTECriteriaBuilderImpl.java index 27d9758615..9a3d9d4af3 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectCTECriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectCTECriteriaBuilderImpl.java @@ -1,46 +1,46 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.List; - -import com.blazebit.persistence.SelectCTECriteriaBuilder; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class SelectCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, Void, Void> implements SelectCTECriteriaBuilder { - - public SelectCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, Y result, CTEBuilderListener listener) { - super(mainQuery, cteName, clazz, result, listener, null); - } - - @Override - public Y end() { - listener.onBuilderEnded(this); - return result; - } - - public CTEInfo createCTEInfo() { - List attributes = prepareAndGetAttributes(); - CTEInfo info = new CTEInfo(cteName, cteType, attributes, false, false, this, null); - return info; - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.List; + +import com.blazebit.persistence.SelectCTECriteriaBuilder; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class SelectCTECriteriaBuilderImpl extends AbstractCTECriteriaBuilder, Void, Void> implements SelectCTECriteriaBuilder { + + public SelectCTECriteriaBuilderImpl(MainQuery mainQuery, String cteName, Class clazz, Y result, CTEBuilderListener listener) { + super(mainQuery, cteName, clazz, result, listener, null); + } + + @Override + public Y end() { + listener.onBuilderEnded(this); + return result; + } + + public CTEInfo createCTEInfo() { + List attributes = prepareAndGetAttributes(); + CTEInfo info = new CTEInfo(cteName, cteType, attributes, false, false, this, null); + return info; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfo.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfo.java index b47364dcfe..4859a17214 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfo.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfo.java @@ -1,52 +1,52 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Moritz Becker - */ -public class SelectInfo extends NodeInfo implements AliasInfo { - - final String alias; - private final AliasManager aliasOwner; - - public SelectInfo(Expression expression) { - super(expression); - this.alias = null; - this.aliasOwner = null; - } - - public SelectInfo(Expression expression, String alias, AliasManager aliasOwner) { - super(expression); - this.alias = alias; - this.aliasOwner = aliasOwner; - } - - @Override - public String getAlias() { - return alias; - } - - @Override - public AliasManager getAliasOwner() { - return aliasOwner; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Moritz Becker + */ +public class SelectInfo extends NodeInfo implements AliasInfo { + + final String alias; + private final AliasManager aliasOwner; + + public SelectInfo(Expression expression) { + super(expression); + this.alias = null; + this.aliasOwner = null; + } + + public SelectInfo(Expression expression, String alias, AliasManager aliasOwner) { + super(expression); + this.alias = alias; + this.aliasOwner = aliasOwner; + } + + @Override + public String getAlias() { + return alias; + } + + @Override + public AliasManager getAliasOwner() { + return aliasOwner; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfoTransformer.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfoTransformer.java index a56a490f01..41dc1b3f0f 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfoTransformer.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfoTransformer.java @@ -1,26 +1,26 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -/** - * - * @author Moritz Becker - */ -public interface SelectInfoTransformer { - - public void transform(SelectInfo info); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +/** + * + * @author Moritz Becker + */ +public interface SelectInfoTransformer { + + public void transform(SelectInfo info); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfoVisitor.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfoVisitor.java index 79f97c35fb..d332b2d83d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfoVisitor.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectInfoVisitor.java @@ -1,26 +1,26 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -/** - * - * @author Moritz Becker - */ -public interface SelectInfoVisitor { - - public void visit(SelectInfo selectInfo); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +/** + * + * @author Moritz Becker + */ +public interface SelectInfoVisitor { + + public void visit(SelectInfo selectInfo); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectObjectBuilderEndedListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectObjectBuilderEndedListener.java index 039365e340..32e84424b8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SelectObjectBuilderEndedListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SelectObjectBuilderEndedListener.java @@ -1,37 +1,37 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.Collection; -import java.util.Map; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public interface SelectObjectBuilderEndedListener { - - /** - * - * @param expressions Collection containing map entries with expressions and their select aliases. - * A select alias is null if none was specified. - */ - public void onBuilderEnded(Collection> expressions); - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.Collection; +import java.util.Map; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public interface SelectObjectBuilderEndedListener { + + /** + * + * @param expressions Collection containing map entries with expressions and their select aliases. + * A select alias is null if none was specified. + */ + public void onBuilderEnded(Collection> expressions); + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SetOperationInfo.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SetOperationInfo.java index 53191234ca..442a83c281 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SetOperationInfo.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SetOperationInfo.java @@ -1,14 +1,14 @@ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.spi.SetOperationType; - - -class SetOperationInfo { - final SetOperationType type; - final AbstractCommonQueryBuilder criteriaBuilder; - - public SetOperationInfo(SetOperationType type, AbstractCommonQueryBuilder criteriaBuilder) { - this.type = type; - this.criteriaBuilder = criteriaBuilder; - } +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.spi.SetOperationType; + + +class SetOperationInfo { + final SetOperationType type; + final AbstractCommonQueryBuilder criteriaBuilder; + + public SetOperationInfo(SetOperationType type, AbstractCommonQueryBuilder criteriaBuilder) { + this.type = type; + this.criteriaBuilder = criteriaBuilder; + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SetOperationManager.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SetOperationManager.java index 720a1deeba..504dc2e4ee 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SetOperationManager.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SetOperationManager.java @@ -1,75 +1,75 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.ArrayList; -import java.util.List; - -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.1.0 - */ -public class SetOperationManager { - - private AbstractCommonQueryBuilder startQueryBuilder; - private SetOperationType operator; - private final boolean nested; - private final List> setOperations; - - SetOperationManager(SetOperationType operator, boolean nested) { - this.operator = operator; - this.nested = nested; - this.setOperations = new ArrayList>(); - } - - List> getSetOperations() { - return setOperations; - } - - boolean hasSetOperations() { - return setOperations.size() > 0; - } - - boolean isNested() { - return nested; - } - - AbstractCommonQueryBuilder getStartQueryBuilder() { - return startQueryBuilder; - } - - void setStartQueryBuilder(AbstractCommonQueryBuilder startQueryBuilder) { - this.startQueryBuilder = startQueryBuilder; - } - - SetOperationType getOperator() { - return operator; - } - - void setOperator(SetOperationType operator) { - this.operator = operator; - } - - void addSetOperation(AbstractCommonQueryBuilder queryBuilder) { - queryBuilder.prepareAndCheck(); - setOperations.add(queryBuilder); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.ArrayList; +import java.util.List; + +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.1.0 + */ +public class SetOperationManager { + + private AbstractCommonQueryBuilder startQueryBuilder; + private SetOperationType operator; + private final boolean nested; + private final List> setOperations; + + SetOperationManager(SetOperationType operator, boolean nested) { + this.operator = operator; + this.nested = nested; + this.setOperations = new ArrayList>(); + } + + List> getSetOperations() { + return setOperations; + } + + boolean hasSetOperations() { + return setOperations.size() > 0; + } + + boolean isNested() { + return nested; + } + + AbstractCommonQueryBuilder getStartQueryBuilder() { + return startQueryBuilder; + } + + void setStartQueryBuilder(AbstractCommonQueryBuilder startQueryBuilder) { + this.startQueryBuilder = startQueryBuilder; + } + + SetOperationType getOperator() { + return operator; + } + + void setOperator(SetOperationType operator) { + this.operator = operator; + } + + void addSetOperation(AbstractCommonQueryBuilder queryBuilder) { + queryBuilder.prepareAndCheck(); + setOperations.add(queryBuilder); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryAndExpressionBuilderListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryAndExpressionBuilderListener.java index 85febb7145..b5cec7c8be 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryAndExpressionBuilderListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryAndExpressionBuilderListener.java @@ -1,68 +1,68 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.SubqueryInitiator; -import com.blazebit.persistence.impl.builder.expression.ExpressionBuilder; -import com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener; -import com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListenerImpl; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @version 1.0 - */ -public class SubqueryAndExpressionBuilderListener implements SubqueryBuilderListener, ExpressionBuilderEndedListener { - - private final SubqueryBuilderListenerImpl subqueryBuilderListener = new SubqueryBuilderListenerImpl(); - private final ExpressionBuilderEndedListenerImpl expressionBuilderEndedListener = new ExpressionBuilderEndedListenerImpl(); - - @Override - public void onReplaceBuilder(SubqueryInternalBuilder oldBuilder, SubqueryInternalBuilder newBuilder) { - subqueryBuilderListener.onReplaceBuilder(oldBuilder, newBuilder); - } - - @Override - public void onBuilderEnded(SubqueryInternalBuilder builder) { - subqueryBuilderListener.onBuilderEnded(builder); - } - - @Override - public void onBuilderStarted(SubqueryInternalBuilder builder) { - subqueryBuilderListener.onBuilderStarted(builder); - } - - @Override - public void onInitiatorStarted(SubqueryInitiator initiator) { - subqueryBuilderListener.onInitiatorStarted(initiator); - } - - @Override - public void onBuilderEnded(ExpressionBuilder builder) { - expressionBuilderEndedListener.onBuilderEnded(builder); - } - - protected void verifyBuilderEnded() { - expressionBuilderEndedListener.verifyBuilderEnded(); - subqueryBuilderListener.verifySubqueryBuilderEnded(); - } - - protected X startBuilder(X builder) { - return expressionBuilderEndedListener.startBuilder(builder); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.SubqueryInitiator; +import com.blazebit.persistence.impl.builder.expression.ExpressionBuilder; +import com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener; +import com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListenerImpl; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @version 1.0 + */ +public class SubqueryAndExpressionBuilderListener implements SubqueryBuilderListener, ExpressionBuilderEndedListener { + + private final SubqueryBuilderListenerImpl subqueryBuilderListener = new SubqueryBuilderListenerImpl(); + private final ExpressionBuilderEndedListenerImpl expressionBuilderEndedListener = new ExpressionBuilderEndedListenerImpl(); + + @Override + public void onReplaceBuilder(SubqueryInternalBuilder oldBuilder, SubqueryInternalBuilder newBuilder) { + subqueryBuilderListener.onReplaceBuilder(oldBuilder, newBuilder); + } + + @Override + public void onBuilderEnded(SubqueryInternalBuilder builder) { + subqueryBuilderListener.onBuilderEnded(builder); + } + + @Override + public void onBuilderStarted(SubqueryInternalBuilder builder) { + subqueryBuilderListener.onBuilderStarted(builder); + } + + @Override + public void onInitiatorStarted(SubqueryInitiator initiator) { + subqueryBuilderListener.onInitiatorStarted(initiator); + } + + @Override + public void onBuilderEnded(ExpressionBuilder builder) { + expressionBuilderEndedListener.onBuilderEnded(builder); + } + + protected void verifyBuilderEnded() { + expressionBuilderEndedListener.verifyBuilderEnded(); + subqueryBuilderListener.verifySubqueryBuilderEnded(); + } + + protected X startBuilder(X builder) { + return expressionBuilderEndedListener.startBuilder(builder); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderImpl.java index 638c14a492..547782c0f6 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderImpl.java @@ -1,80 +1,80 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.ArrayList; -import java.util.List; - -import com.blazebit.persistence.LeafOngoingSetOperationSubqueryBuilder; -import com.blazebit.persistence.StartOngoingSetOperationSubqueryBuilder; -import com.blazebit.persistence.SubqueryBuilder; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class SubqueryBuilderImpl extends BaseSubqueryBuilderImpl, LeafOngoingSetOperationSubqueryBuilder, StartOngoingSetOperationSubqueryBuilder>> implements SubqueryBuilder, SubqueryInternalBuilder { - - public SubqueryBuilderImpl(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager, ExpressionFactory expressionFactory, T result, SubqueryBuilderListener listener) { - super(mainQuery, aliasManager, parentJoinManager, expressionFactory, result, listener, null); - } - - @Override - public List getSelectExpressions() { - List selectExpressions = new ArrayList(selectManager.getSelectInfos().size()); - - for (SelectInfo info : selectManager.getSelectInfos()) { - selectExpressions.add(info.getExpression()); - } - - return selectExpressions; - } - - @Override - public T end() { - listener.onBuilderEnded(this); - return result; - } - - public T getResult() { - return result; - } - - @Override - protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { - return createFinalSetOperationBuilder(operator, nested, nested, this); - } - - @Override - protected LeafOngoingSetOperationSubqueryBuilder createSetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { - subListener.verifySubqueryBuilderEnded(); - listener.onReplaceBuilder(this, finalSetOperationBuilder); - return createLeaf(finalSetOperationBuilder); - } - - @Override - protected StartOngoingSetOperationSubqueryBuilder> createSubquerySetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationSubqueryBuilderImpl resultFinalSetOperationBuilder) { - subListener.verifySubqueryBuilderEnded(); - listener.onReplaceBuilder(this, resultFinalSetOperationBuilder); - LeafOngoingSetOperationSubqueryBuilder leafCb = createSetOperand(resultFinalSetOperationBuilder); - return createOngoing(finalSetOperationBuilder, leafCb); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.ArrayList; +import java.util.List; + +import com.blazebit.persistence.LeafOngoingSetOperationSubqueryBuilder; +import com.blazebit.persistence.StartOngoingSetOperationSubqueryBuilder; +import com.blazebit.persistence.SubqueryBuilder; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class SubqueryBuilderImpl extends BaseSubqueryBuilderImpl, LeafOngoingSetOperationSubqueryBuilder, StartOngoingSetOperationSubqueryBuilder>> implements SubqueryBuilder, SubqueryInternalBuilder { + + public SubqueryBuilderImpl(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager, ExpressionFactory expressionFactory, T result, SubqueryBuilderListener listener) { + super(mainQuery, aliasManager, parentJoinManager, expressionFactory, result, listener, null); + } + + @Override + public List getSelectExpressions() { + List selectExpressions = new ArrayList(selectManager.getSelectInfos().size()); + + for (SelectInfo info : selectManager.getSelectInfos()) { + selectExpressions.add(info.getExpression()); + } + + return selectExpressions; + } + + @Override + public T end() { + listener.onBuilderEnded(this); + return result; + } + + public T getResult() { + return result; + } + + @Override + protected BaseFinalSetOperationSubqueryBuilderImpl createFinalSetOperationBuilder(SetOperationType operator, boolean nested) { + return createFinalSetOperationBuilder(operator, nested, nested, this); + } + + @Override + protected LeafOngoingSetOperationSubqueryBuilder createSetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder) { + subListener.verifySubqueryBuilderEnded(); + listener.onReplaceBuilder(this, finalSetOperationBuilder); + return createLeaf(finalSetOperationBuilder); + } + + @Override + protected StartOngoingSetOperationSubqueryBuilder> createSubquerySetOperand(BaseFinalSetOperationSubqueryBuilderImpl finalSetOperationBuilder, BaseFinalSetOperationSubqueryBuilderImpl resultFinalSetOperationBuilder) { + subListener.verifySubqueryBuilderEnded(); + listener.onReplaceBuilder(this, resultFinalSetOperationBuilder); + LeafOngoingSetOperationSubqueryBuilder leafCb = createSetOperand(resultFinalSetOperationBuilder); + return createOngoing(finalSetOperationBuilder, leafCb); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderListener.java index f4584847fd..ece55ada6f 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderListener.java @@ -1,35 +1,35 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.SubqueryInitiator; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public interface SubqueryBuilderListener { - - public void onReplaceBuilder(SubqueryInternalBuilder oldBuilder, SubqueryInternalBuilder newBuilder); - - public void onBuilderEnded(SubqueryInternalBuilder builder); - - public void onBuilderStarted(SubqueryInternalBuilder builder); - - public void onInitiatorStarted(SubqueryInitiator initiator); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.SubqueryInitiator; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public interface SubqueryBuilderListener { + + public void onReplaceBuilder(SubqueryInternalBuilder oldBuilder, SubqueryInternalBuilder newBuilder); + + public void onBuilderEnded(SubqueryInternalBuilder builder); + + public void onBuilderStarted(SubqueryInternalBuilder builder); + + public void onInitiatorStarted(SubqueryInitiator initiator); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderListenerImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderListenerImpl.java index 10e2808d16..27fd4beaf2 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderListenerImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryBuilderListenerImpl.java @@ -1,79 +1,79 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.SubqueryInitiator; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class SubqueryBuilderListenerImpl implements SubqueryBuilderListener { - - private SubqueryInitiator currentSubqueryInitiator; - private SubqueryInternalBuilder currentSubqueryBuilder; - - public void onReplaceBuilder(SubqueryInternalBuilder oldBuilder, SubqueryInternalBuilder newBuilder) { - if (currentSubqueryBuilder == null) { - throw new BuilderChainingException("There was an attempt to replace a builder that was not started or already closed."); - } - if (currentSubqueryBuilder != oldBuilder) { - throw new BuilderChainingException("There was an attempt to replace a builder that was not started or already closed."); - } - currentSubqueryBuilder = newBuilder; - } - - public void verifySubqueryBuilderEnded() { - if (currentSubqueryInitiator != null) { - throw new BuilderChainingException("An initiator was not ended properly."); - } - if (currentSubqueryBuilder != null) { - throw new BuilderChainingException("A builder was not ended properly."); - } - } - - @Override - public void onBuilderEnded(SubqueryInternalBuilder builder) { - if (currentSubqueryBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - currentSubqueryBuilder = null; - } - - @Override - public void onBuilderStarted(SubqueryInternalBuilder builder) { - if (currentSubqueryBuilder != null) { - throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); - } - - currentSubqueryInitiator = null; - currentSubqueryBuilder = builder; - } - - @Override - public void onInitiatorStarted(SubqueryInitiator initiator) { - if (currentSubqueryInitiator != null) { - throw new BuilderChainingException("There was an attempt to start an initiator but a previous initiator was not ended."); - } - if (currentSubqueryBuilder != null) { - throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); - } - - currentSubqueryInitiator = initiator; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.SubqueryInitiator; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class SubqueryBuilderListenerImpl implements SubqueryBuilderListener { + + private SubqueryInitiator currentSubqueryInitiator; + private SubqueryInternalBuilder currentSubqueryBuilder; + + public void onReplaceBuilder(SubqueryInternalBuilder oldBuilder, SubqueryInternalBuilder newBuilder) { + if (currentSubqueryBuilder == null) { + throw new BuilderChainingException("There was an attempt to replace a builder that was not started or already closed."); + } + if (currentSubqueryBuilder != oldBuilder) { + throw new BuilderChainingException("There was an attempt to replace a builder that was not started or already closed."); + } + currentSubqueryBuilder = newBuilder; + } + + public void verifySubqueryBuilderEnded() { + if (currentSubqueryInitiator != null) { + throw new BuilderChainingException("An initiator was not ended properly."); + } + if (currentSubqueryBuilder != null) { + throw new BuilderChainingException("A builder was not ended properly."); + } + } + + @Override + public void onBuilderEnded(SubqueryInternalBuilder builder) { + if (currentSubqueryBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + currentSubqueryBuilder = null; + } + + @Override + public void onBuilderStarted(SubqueryInternalBuilder builder) { + if (currentSubqueryBuilder != null) { + throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); + } + + currentSubqueryInitiator = null; + currentSubqueryBuilder = builder; + } + + @Override + public void onInitiatorStarted(SubqueryInitiator initiator) { + if (currentSubqueryInitiator != null) { + throw new BuilderChainingException("There was an attempt to start an initiator but a previous initiator was not ended."); + } + if (currentSubqueryBuilder != null) { + throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); + } + + currentSubqueryInitiator = initiator; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryInitiatorFactory.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryInitiatorFactory.java index bc0d1f09b9..0f52e7b717 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryInitiatorFactory.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryInitiatorFactory.java @@ -1,40 +1,40 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.SubqueryInitiator; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class SubqueryInitiatorFactory { - - private final MainQuery mainQuery; - private final AliasManager aliasManager; - private final JoinManager parentJoinManager; - - public SubqueryInitiatorFactory(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager) { - this.mainQuery = mainQuery; - this.aliasManager = aliasManager; - this.parentJoinManager = parentJoinManager; - } - - public SubqueryInitiator createSubqueryInitiator(T result, SubqueryBuilderListener listener) { - return new SubqueryInitiatorImpl(mainQuery, aliasManager, parentJoinManager, result, listener); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.SubqueryInitiator; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class SubqueryInitiatorFactory { + + private final MainQuery mainQuery; + private final AliasManager aliasManager; + private final JoinManager parentJoinManager; + + public SubqueryInitiatorFactory(MainQuery mainQuery, AliasManager aliasManager, JoinManager parentJoinManager) { + this.mainQuery = mainQuery; + this.aliasManager = aliasManager; + this.parentJoinManager = parentJoinManager; + } + + public SubqueryInitiator createSubqueryInitiator(T result, SubqueryBuilderListener listener) { + return new SubqueryInitiatorImpl(mainQuery, aliasManager, parentJoinManager, result, listener); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryInternalBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryInternalBuilder.java index cfdf820efe..5dbac62a9d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryInternalBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryInternalBuilder.java @@ -1,38 +1,38 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import java.util.List; - -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.Subquery; - -/** - * - * @author Christian Beikov - * @since 1.1.0 - */ -public interface SubqueryInternalBuilder extends Subquery { - - public T getResult(); - - public List getSelectExpressions(); - - public int getFirstResult(); - - public int getMaxResults(); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import java.util.List; + +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.Subquery; + +/** + * + * @author Christian Beikov + * @since 1.1.0 + */ +public interface SubqueryInternalBuilder extends Subquery { + + public T getResult(); + + public List getSelectExpressions(); + + public int getFirstResult(); + + public int getMaxResults(); + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryRecursiveExpressionTransformer.java b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryRecursiveExpressionTransformer.java index a929aaf49d..ef7483d52b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryRecursiveExpressionTransformer.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/SubqueryRecursiveExpressionTransformer.java @@ -1,41 +1,41 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.SubqueryExpression; -import com.blazebit.persistence.impl.expression.VisitorAdapter; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SubqueryRecursiveExpressionTransformer extends VisitorAdapter implements ExpressionTransformer { - - @Override - public Expression transform(Expression original, ClauseType fromClause, boolean joinRequired) { - original.accept(this); - return original; - } - - @Override - public void visit(SubqueryExpression expression) { - // TODO: this is ugly - ((AbstractCommonQueryBuilder) expression.getSubquery()).applyExpressionTransformers(); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.SubqueryExpression; +import com.blazebit.persistence.impl.expression.VisitorAdapter; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SubqueryRecursiveExpressionTransformer extends VisitorAdapter implements ExpressionTransformer { + + @Override + public Expression transform(Expression original, ClauseType fromClause, boolean joinRequired) { + original.accept(this); + return original; + } + + @Override + public void visit(SubqueryExpression expression) { + // TODO: this is ugly + ((AbstractCommonQueryBuilder) expression.getSubquery()).applyExpressionTransformers(); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/UpdateCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/UpdateCriteriaBuilderImpl.java index 50cb5df7ee..6ffacf15e3 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/UpdateCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/UpdateCriteriaBuilderImpl.java @@ -1,32 +1,32 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl; - -import com.blazebit.persistence.UpdateCriteriaBuilder; - -/** - * - * @param The query result type - * @author Christian Beikov - * @since 1.1.0 - */ -public class UpdateCriteriaBuilderImpl extends BaseUpdateCriteriaBuilderImpl, Void> implements UpdateCriteriaBuilder { - - public UpdateCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String alias) { - super(mainQuery, true, clazz, alias, null, null, null, null); - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl; + +import com.blazebit.persistence.UpdateCriteriaBuilder; + +/** + * + * @param The query result type + * @author Christian Beikov + * @since 1.1.0 + */ +public class UpdateCriteriaBuilderImpl extends BaseUpdateCriteriaBuilderImpl, Void> implements UpdateCriteriaBuilder { + + public UpdateCriteriaBuilderImpl(MainQuery mainQuery, Class clazz, String alias) { + super(mainQuery, true, clazz, alias, null, null, null, null); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/Version.java b/core/impl/src/main/java/com/blazebit/persistence/impl/Version.java index d2b36e8168..b98288fb2d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/Version.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/Version.java @@ -1,30 +1,30 @@ -package com.blazebit.persistence.impl; - -public class Version { - - public static final String PROJECT_NAME = "Blaze-Persistence"; - - private Version() { - } - - public static String getVersion() { - return Injected.getVersion(); - } - - public static String printVersion() { - return PROJECT_NAME + " '" + Injected.getCodename() + "' " + Injected.getVersion(); - } - - static class Injected { - - static String getVersion() { - // Will be replaced by the Maven Injection plugin - return "0.0.0-SNAPSHOT"; - } - - static String getCodename() { - // Will be replaced by the Maven Injection plugin - return ""; - } - } -} +package com.blazebit.persistence.impl; + +public class Version { + + public static final String PROJECT_NAME = "Blaze-Persistence"; + + private Version() { + } + + public static String getVersion() { + return Injected.getVersion(); + } + + public static String printVersion() { + return PROJECT_NAME + " '" + Injected.getCodename() + "' " + Injected.getVersion(); + } + + static class Injected { + + static String getVersion() { + // Will be replaced by the Maven Injection plugin + return "0.0.0-SNAPSHOT"; + } + + static String getCodename() { + // Will be replaced by the Maven Injection plugin + return ""; + } + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/EscapeBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/EscapeBuilderImpl.java index ba1a10d86a..641e4bbd85 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/EscapeBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/EscapeBuilderImpl.java @@ -1,79 +1,79 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.expression; - -import com.blazebit.persistence.EscapeBuilder; -import com.blazebit.persistence.impl.BuilderChainingException; - -/** - * - * @author Moritz Becker - */ -public class EscapeBuilderImpl implements EscapeBuilder { - - private final EscapeBuilderImplEndedListener listener; - private final T result; - private Character escapeCharacter; - - public EscapeBuilderImpl(EscapeBuilderImplEndedListener listener, T result) { - this.listener = listener; - this.result = result; - } - - @Override - public T escape(char c) { - escapeCharacter = c; - listener.onBuilderEnded(this); - return result; - } - - @Override - public T noEscape() { - listener.onBuilderEnded(this); - return result; - } - - public Character getEscapeCharacter() { - return escapeCharacter; - } - - public static class EscapeBuilderImplEndedListener { - - private EscapeBuilderImpl currentBuilder; - - public void verifyBuilderEnded() { - if (currentBuilder != null) { - throw new BuilderChainingException("A builder was not ended properly."); - } - } - - public > T startBuilder(T builder) { - if (currentBuilder != null) { - throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); - } - - currentBuilder = builder; - return builder; - } - - public void onBuilderEnded(EscapeBuilderImpl builder) { - if (currentBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - currentBuilder = null; - } - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.expression; + +import com.blazebit.persistence.EscapeBuilder; +import com.blazebit.persistence.impl.BuilderChainingException; + +/** + * + * @author Moritz Becker + */ +public class EscapeBuilderImpl implements EscapeBuilder { + + private final EscapeBuilderImplEndedListener listener; + private final T result; + private Character escapeCharacter; + + public EscapeBuilderImpl(EscapeBuilderImplEndedListener listener, T result) { + this.listener = listener; + this.result = result; + } + + @Override + public T escape(char c) { + escapeCharacter = c; + listener.onBuilderEnded(this); + return result; + } + + @Override + public T noEscape() { + listener.onBuilderEnded(this); + return result; + } + + public Character getEscapeCharacter() { + return escapeCharacter; + } + + public static class EscapeBuilderImplEndedListener { + + private EscapeBuilderImpl currentBuilder; + + public void verifyBuilderEnded() { + if (currentBuilder != null) { + throw new BuilderChainingException("A builder was not ended properly."); + } + } + + public > T startBuilder(T builder) { + if (currentBuilder != null) { + throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); + } + + currentBuilder = builder; + return builder; + } + + public void onBuilderEnded(EscapeBuilderImpl builder) { + if (currentBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + currentBuilder = null; + } + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilder.java index 8b9bf02977..fc220bd090 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilder.java @@ -1,28 +1,28 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.builder.expression; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Moritz Becker - */ -public interface ExpressionBuilder { - - public Expression getExpression(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.builder.expression; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Moritz Becker + */ +public interface ExpressionBuilder { + + public Expression getExpression(); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilderEndedListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilderEndedListener.java index 99878584dc..8260c32047 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilderEndedListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilderEndedListener.java @@ -1,27 +1,27 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public interface ExpressionBuilderEndedListener { - - public void onBuilderEnded(ExpressionBuilder builder); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public interface ExpressionBuilderEndedListener { + + public void onBuilderEnded(ExpressionBuilder builder); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilderEndedListenerImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilderEndedListenerImpl.java index d1c7a9e7d0..1107931d07 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilderEndedListenerImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/ExpressionBuilderEndedListenerImpl.java @@ -1,53 +1,53 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.expression; - -import com.blazebit.persistence.impl.BuilderChainingException; - -/** - * A base class that provides functionality to start and stop builders in a manner, such that only one builder can be started at a time. - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class ExpressionBuilderEndedListenerImpl implements ExpressionBuilderEndedListener { - - private ExpressionBuilder currentBuilder; - - public void verifyBuilderEnded() { - if (currentBuilder != null) { - throw new BuilderChainingException("A builder was not ended properly."); - } - } - - public T startBuilder(T builder) { - if (currentBuilder != null) { - throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); - } - - currentBuilder = builder; - return builder; - } - - @Override - public void onBuilderEnded(ExpressionBuilder builder) { - if (currentBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - currentBuilder = null; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.expression; + +import com.blazebit.persistence.impl.BuilderChainingException; + +/** + * A base class that provides functionality to start and stop builders in a manner, such that only one builder can be started at a time. + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class ExpressionBuilderEndedListenerImpl implements ExpressionBuilderEndedListener { + + private ExpressionBuilder currentBuilder; + + public void verifyBuilderEnded() { + if (currentBuilder != null) { + throw new BuilderChainingException("A builder was not ended properly."); + } + } + + public T startBuilder(T builder) { + if (currentBuilder != null) { + throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); + } + + currentBuilder = builder; + return builder; + } + + @Override + public void onBuilderEnded(ExpressionBuilder builder) { + if (currentBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + currentBuilder = null; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/SimpleCaseWhenBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/SimpleCaseWhenBuilderImpl.java index 011f4c7da6..d740b73f1b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/SimpleCaseWhenBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/expression/SimpleCaseWhenBuilderImpl.java @@ -1,71 +1,71 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.expression; - -import java.util.ArrayList; -import java.util.List; - -import com.blazebit.persistence.SimpleCaseWhenBuilder; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.impl.expression.SimpleCaseExpression; -import com.blazebit.persistence.impl.expression.WhenClauseExpression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class SimpleCaseWhenBuilderImpl implements SimpleCaseWhenBuilder, ExpressionBuilder { - - private final T result; - private final Expression caseOperandExpression; - private final List whenExpressions; - private SimpleCaseExpression expression; - private final ExpressionFactory expressionFactory; - private final ExpressionBuilderEndedListener listener; - - public SimpleCaseWhenBuilderImpl(T result, ExpressionBuilderEndedListener listener, ExpressionFactory expressionFactory, Expression caseOperandExpression) { - this.result = result; - this.caseOperandExpression = caseOperandExpression; - this.whenExpressions = new ArrayList(); - this.expressionFactory = expressionFactory; - this.listener = listener; - } - - @Override - public SimpleCaseWhenBuilder when(String condition, String thenExpression) { - whenExpressions.add(new WhenClauseExpression(expressionFactory.createScalarExpression(condition), expressionFactory.createScalarExpression(thenExpression))); - return this; - } - - @Override - public T otherwise(String elseExpression) { - if (whenExpressions.isEmpty()) { - throw new IllegalStateException("No when clauses specified"); - } - expression = new SimpleCaseExpression(caseOperandExpression, whenExpressions, expressionFactory.createScalarExpression(elseExpression)); - listener.onBuilderEnded(this); - return result; - } - - @Override - public Expression getExpression() { - return expression; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.expression; + +import java.util.ArrayList; +import java.util.List; + +import com.blazebit.persistence.SimpleCaseWhenBuilder; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.impl.expression.SimpleCaseExpression; +import com.blazebit.persistence.impl.expression.WhenClauseExpression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class SimpleCaseWhenBuilderImpl implements SimpleCaseWhenBuilder, ExpressionBuilder { + + private final T result; + private final Expression caseOperandExpression; + private final List whenExpressions; + private SimpleCaseExpression expression; + private final ExpressionFactory expressionFactory; + private final ExpressionBuilderEndedListener listener; + + public SimpleCaseWhenBuilderImpl(T result, ExpressionBuilderEndedListener listener, ExpressionFactory expressionFactory, Expression caseOperandExpression) { + this.result = result; + this.caseOperandExpression = caseOperandExpression; + this.whenExpressions = new ArrayList(); + this.expressionFactory = expressionFactory; + this.listener = listener; + } + + @Override + public SimpleCaseWhenBuilder when(String condition, String thenExpression) { + whenExpressions.add(new WhenClauseExpression(expressionFactory.createScalarExpression(condition), expressionFactory.createScalarExpression(thenExpression))); + return this; + } + + @Override + public T otherwise(String elseExpression) { + if (whenExpressions.isEmpty()) { + throw new IllegalStateException("No when clauses specified"); + } + expression = new SimpleCaseExpression(caseOperandExpression, whenExpressions, expressionFactory.createScalarExpression(elseExpression)); + listener.onBuilderEnded(this); + return result; + } + + @Override + public Expression getExpression() { + return expression; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ClassObjectBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ClassObjectBuilder.java index ef2f4a95b4..0e40081c2f 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ClassObjectBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ClassObjectBuilder.java @@ -1,87 +1,87 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.object; - -import java.lang.reflect.Constructor; -import java.util.List; - -import com.blazebit.persistence.ObjectBuilder; -import com.blazebit.persistence.SelectBuilder; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class ClassObjectBuilder implements ObjectBuilder { - - private final Class clazz; - private Constructor constructor; - - public ClassObjectBuilder(Class clazz) { - this.clazz = clazz; - } - - @SuppressWarnings("unchecked") - private Constructor getConstructor(Object[] tuple) { - Constructor[] constructors = clazz.getConstructors(); - Constructor matchingConstr = null; - for (Constructor constr : constructors) { - Class[] paramTypes = constr.getParameterTypes(); - if (paramTypes.length == tuple.length) { - boolean match = true; - for (int i = 0; i < paramTypes.length; i++) { - if (tuple[i] != null && !paramTypes[i].isAssignableFrom(tuple[i].getClass())) { - match = false; - break; - } - } - if (match == true) { - if (matchingConstr != null) { - throw new RuntimeException("Multiple constructors matching"); - } - return (Constructor) constr; - } - - } - } - - throw new RuntimeException("No matching constructor"); - } - - @Override - public T build(Object[] tuple) { - if (constructor == null) { - constructor = getConstructor(tuple); - } - - try { - return constructor.newInstance(tuple); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public List buildList(List list) { - return list; - } - - @Override - public > void applySelects(X queryBuilder) { - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.object; + +import java.lang.reflect.Constructor; +import java.util.List; + +import com.blazebit.persistence.ObjectBuilder; +import com.blazebit.persistence.SelectBuilder; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class ClassObjectBuilder implements ObjectBuilder { + + private final Class clazz; + private Constructor constructor; + + public ClassObjectBuilder(Class clazz) { + this.clazz = clazz; + } + + @SuppressWarnings("unchecked") + private Constructor getConstructor(Object[] tuple) { + Constructor[] constructors = clazz.getConstructors(); + Constructor matchingConstr = null; + for (Constructor constr : constructors) { + Class[] paramTypes = constr.getParameterTypes(); + if (paramTypes.length == tuple.length) { + boolean match = true; + for (int i = 0; i < paramTypes.length; i++) { + if (tuple[i] != null && !paramTypes[i].isAssignableFrom(tuple[i].getClass())) { + match = false; + break; + } + } + if (match == true) { + if (matchingConstr != null) { + throw new RuntimeException("Multiple constructors matching"); + } + return (Constructor) constr; + } + + } + } + + throw new RuntimeException("No matching constructor"); + } + + @Override + public T build(Object[] tuple) { + if (constructor == null) { + constructor = getConstructor(tuple); + } + + try { + return constructor.newInstance(tuple); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public List buildList(List list) { + return list; + } + + @Override + public > void applySelects(X queryBuilder) { + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ConstructorObjectBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ConstructorObjectBuilder.java index fbfc172529..704d4d483d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ConstructorObjectBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ConstructorObjectBuilder.java @@ -1,59 +1,59 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.object; - -import java.lang.reflect.Constructor; -import java.util.List; - -import com.blazebit.persistence.ObjectBuilder; -import com.blazebit.persistence.SelectBuilder; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class ConstructorObjectBuilder implements ObjectBuilder { - - private final Constructor constructor; - - public ConstructorObjectBuilder(Constructor constructor) { - this.constructor = constructor; - } - - @Override - public T build(Object[] tuple) { - if (constructor.getParameterTypes().length != tuple.length) { - throw new RuntimeException("Constructor expects " + constructor.getParameterTypes().length + " arguments but " + tuple.length - + " arguments were queried"); - } - try { - return constructor.newInstance(tuple); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public List buildList(List list) { - return list; - } - - @Override - public > void applySelects(X queryBuilder) { - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.object; + +import java.lang.reflect.Constructor; +import java.util.List; + +import com.blazebit.persistence.ObjectBuilder; +import com.blazebit.persistence.SelectBuilder; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class ConstructorObjectBuilder implements ObjectBuilder { + + private final Constructor constructor; + + public ConstructorObjectBuilder(Constructor constructor) { + this.constructor = constructor; + } + + @Override + public T build(Object[] tuple) { + if (constructor.getParameterTypes().length != tuple.length) { + throw new RuntimeException("Constructor expects " + constructor.getParameterTypes().length + " arguments but " + tuple.length + + " arguments were queried"); + } + try { + return constructor.newInstance(tuple); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public List buildList(List list) { + return list; + } + + @Override + public > void applySelects(X queryBuilder) { + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/DelegatingKeysetExtractionObjectBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/DelegatingKeysetExtractionObjectBuilder.java index afd246684e..cce865fa38 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/DelegatingKeysetExtractionObjectBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/DelegatingKeysetExtractionObjectBuilder.java @@ -1,52 +1,52 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.object; - -import java.util.List; - -import com.blazebit.persistence.ObjectBuilder; -import com.blazebit.persistence.SelectBuilder; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DelegatingKeysetExtractionObjectBuilder extends KeysetExtractionObjectBuilder { - - private final ObjectBuilder objectBuilder; - - public DelegatingKeysetExtractionObjectBuilder(ObjectBuilder objectBuilder, int keysetSize) { - super(keysetSize); - this.objectBuilder = objectBuilder; - } - - @Override - public T build(Object[] tuple) { - return objectBuilder.build((Object[]) super.build(tuple)); - } - - @Override - public List buildList(List list) { - return objectBuilder.buildList(list); - } - - @Override - public > void applySelects(X selectBuilder) { - objectBuilder.applySelects(selectBuilder); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.object; + +import java.util.List; + +import com.blazebit.persistence.ObjectBuilder; +import com.blazebit.persistence.SelectBuilder; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DelegatingKeysetExtractionObjectBuilder extends KeysetExtractionObjectBuilder { + + private final ObjectBuilder objectBuilder; + + public DelegatingKeysetExtractionObjectBuilder(ObjectBuilder objectBuilder, int keysetSize) { + super(keysetSize); + this.objectBuilder = objectBuilder; + } + + @Override + public T build(Object[] tuple) { + return objectBuilder.build((Object[]) super.build(tuple)); + } + + @Override + public List buildList(List list) { + return objectBuilder.buildList(list); + } + + @Override + public > void applySelects(X selectBuilder) { + objectBuilder.applySelects(selectBuilder); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/KeysetExtractionObjectBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/KeysetExtractionObjectBuilder.java index a3af36c89e..e9afe9b874 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/KeysetExtractionObjectBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/KeysetExtractionObjectBuilder.java @@ -1,81 +1,81 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.object; - -import java.io.Serializable; -import java.util.List; - -import com.blazebit.persistence.ObjectBuilder; -import com.blazebit.persistence.SelectBuilder; -import com.blazebit.persistence.impl.keyset.KeysetPaginationHelper; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class KeysetExtractionObjectBuilder implements ObjectBuilder { - - private final int keysetSize; - private Object[] first; - private Object[] last; - - public KeysetExtractionObjectBuilder(int keysetSize) { - this.keysetSize = keysetSize; - } - - @SuppressWarnings("unchecked") - @Override - public T build(Object[] tuple) { - Object[] newTuple = new Object[tuple.length - keysetSize]; - System.arraycopy(tuple, 0, newTuple, 0, newTuple.length); - - if (first == null) { - first = tuple; - last = tuple; - } else { - last = tuple; - } - - return (T) newTuple; - } - - public Serializable[] getLowest() { - if (first == null) { - return null; - } - - return KeysetPaginationHelper.extractKey(first, first.length - keysetSize); - } - - public Serializable[] getHighest() { - if (last == null) { - return null; - } - - return KeysetPaginationHelper.extractKey(last, last.length - keysetSize); - } - - @Override - public List buildList(List list) { - return list; - } - - @Override - public > void applySelects(X queryBuilder) { - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.object; + +import java.io.Serializable; +import java.util.List; + +import com.blazebit.persistence.ObjectBuilder; +import com.blazebit.persistence.SelectBuilder; +import com.blazebit.persistence.impl.keyset.KeysetPaginationHelper; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class KeysetExtractionObjectBuilder implements ObjectBuilder { + + private final int keysetSize; + private Object[] first; + private Object[] last; + + public KeysetExtractionObjectBuilder(int keysetSize) { + this.keysetSize = keysetSize; + } + + @SuppressWarnings("unchecked") + @Override + public T build(Object[] tuple) { + Object[] newTuple = new Object[tuple.length - keysetSize]; + System.arraycopy(tuple, 0, newTuple, 0, newTuple.length); + + if (first == null) { + first = tuple; + last = tuple; + } else { + last = tuple; + } + + return (T) newTuple; + } + + public Serializable[] getLowest() { + if (first == null) { + return null; + } + + return KeysetPaginationHelper.extractKey(first, first.length - keysetSize); + } + + public Serializable[] getHighest() { + if (last == null) { + return null; + } + + return KeysetPaginationHelper.extractKey(last, last.length - keysetSize); + } + + @Override + public List buildList(List list) { + return list; + } + + @Override + public > void applySelects(X queryBuilder) { + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ReturningTupleObjectBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ReturningTupleObjectBuilder.java index a64a6ad8e9..82cb62cdf8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ReturningTupleObjectBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/object/ReturningTupleObjectBuilder.java @@ -1,147 +1,147 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.object; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.persistence.Tuple; -import javax.persistence.TupleElement; - -import com.blazebit.persistence.ReturningBuilder; -import com.blazebit.persistence.ReturningObjectBuilder; - -/** - * - * @author Christian Beikov - * @since 1.1.0 - */ -public class ReturningTupleObjectBuilder implements ReturningObjectBuilder { - - @Override - public Tuple build(Object[] tuple) { - return new TupleImpl(tuple); - } - - @Override - public List buildList(List list) { - return list; - } - - @Override - public > void applyReturning(X queryBuilder) { - } - - private class TupleImpl implements Tuple { - - private final Object[] tuple; - private List> tupleElements; - - private TupleImpl(Object[] tuple) { - this.tuple = tuple; - } - - @Override - public X get(TupleElement tupleElement) { - return get(tupleElement.getAlias(), tupleElement.getJavaType()); - } - - @Override - public Object get(String alias) { - throw new IllegalArgumentException("There were no aliases defined for this result!"); - } - - @Override - public X get(String alias, Class type) { - throw new IllegalArgumentException("There were no aliases defined for this result!"); - } - - @Override - public Object get(int i) { - if (i >= tuple.length || i < 0) { - throw new IllegalArgumentException("Given index [" + i + "] was outside the range of result tuple size [" + tuple.length + "] "); - } - return tuple[i]; - } - - @Override - public X get(int i, Class type) { - return type.cast(get(i)); - } - - @Override - public Object[] toArray() { - return tuple.clone(); - } - - @Override - public List> getElements() { - if (tupleElements == null) { - tupleElements = new ArrayList>(tuple.length); - for (int i = 0; i < tuple.length; i++) { - tupleElements.add(new TupleElementImpl(i)); - } - } - - return tupleElements; - } - - private class TupleElementImpl implements TupleElement { - - private final int index; - - public TupleElementImpl(int index) { - this.index = index; - } - - @Override - @SuppressWarnings("unchecked") - public Class getJavaType() { - return (Class) tuple[index]; - } - - @Override - public String getAlias() { - return null; - } - } - - @Override - public int hashCode() { - int hash = 5; - hash = 29 * hash + Arrays.deepHashCode(this.tuple); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TupleImpl other = (TupleImpl) obj; - if (!Arrays.deepEquals(this.tuple, other.tuple)) { - return false; - } - return true; - } - - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.object; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.persistence.Tuple; +import javax.persistence.TupleElement; + +import com.blazebit.persistence.ReturningBuilder; +import com.blazebit.persistence.ReturningObjectBuilder; + +/** + * + * @author Christian Beikov + * @since 1.1.0 + */ +public class ReturningTupleObjectBuilder implements ReturningObjectBuilder { + + @Override + public Tuple build(Object[] tuple) { + return new TupleImpl(tuple); + } + + @Override + public List buildList(List list) { + return list; + } + + @Override + public > void applyReturning(X queryBuilder) { + } + + private class TupleImpl implements Tuple { + + private final Object[] tuple; + private List> tupleElements; + + private TupleImpl(Object[] tuple) { + this.tuple = tuple; + } + + @Override + public X get(TupleElement tupleElement) { + return get(tupleElement.getAlias(), tupleElement.getJavaType()); + } + + @Override + public Object get(String alias) { + throw new IllegalArgumentException("There were no aliases defined for this result!"); + } + + @Override + public X get(String alias, Class type) { + throw new IllegalArgumentException("There were no aliases defined for this result!"); + } + + @Override + public Object get(int i) { + if (i >= tuple.length || i < 0) { + throw new IllegalArgumentException("Given index [" + i + "] was outside the range of result tuple size [" + tuple.length + "] "); + } + return tuple[i]; + } + + @Override + public X get(int i, Class type) { + return type.cast(get(i)); + } + + @Override + public Object[] toArray() { + return tuple.clone(); + } + + @Override + public List> getElements() { + if (tupleElements == null) { + tupleElements = new ArrayList>(tuple.length); + for (int i = 0; i < tuple.length; i++) { + tupleElements.add(new TupleElementImpl(i)); + } + } + + return tupleElements; + } + + private class TupleElementImpl implements TupleElement { + + private final int index; + + public TupleElementImpl(int index) { + this.index = index; + } + + @Override + @SuppressWarnings("unchecked") + public Class getJavaType() { + return (Class) tuple[index]; + } + + @Override + public String getAlias() { + return null; + } + } + + @Override + public int hashCode() { + int hash = 5; + hash = 29 * hash + Arrays.deepHashCode(this.tuple); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final TupleImpl other = (TupleImpl) obj; + if (!Arrays.deepEquals(this.tuple, other.tuple)) { + return false; + } + return true; + } + + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/CaseExpressionBuilderListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/CaseExpressionBuilderListener.java index dcf13b3cdb..d8e3c30889 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/CaseExpressionBuilderListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/CaseExpressionBuilderListener.java @@ -1,40 +1,40 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.builder.expression.ExpressionBuilder; -import com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListenerImpl; - -/** - * - * @author Moritz Becker - */ -public class CaseExpressionBuilderListener extends ExpressionBuilderEndedListenerImpl { - - private final LeftHandsideSubqueryPredicateBuilder restrictionBuilder; - - public CaseExpressionBuilderListener(LeftHandsideSubqueryPredicateBuilder restrictionBuilder) { - this.restrictionBuilder = restrictionBuilder; - } - - @Override - public void onBuilderEnded(ExpressionBuilder builder) { - super.onBuilderEnded(builder); - restrictionBuilder.setLeftExpression(builder.getExpression()); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.builder.expression.ExpressionBuilder; +import com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListenerImpl; + +/** + * + * @author Moritz Becker + */ +public class CaseExpressionBuilderListener extends ExpressionBuilderEndedListenerImpl { + + private final LeftHandsideSubqueryPredicateBuilder restrictionBuilder; + + public CaseExpressionBuilderListener(LeftHandsideSubqueryPredicateBuilder restrictionBuilder) { + this.restrictionBuilder = restrictionBuilder; + } + + @Override + public void onBuilderEnded(ExpressionBuilder builder) { + super.onBuilderEnded(builder); + restrictionBuilder.setLeftExpression(builder.getExpression()); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/EqPredicateBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/EqPredicateBuilder.java index e5143af057..2f92866f92 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/EqPredicateBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/EqPredicateBuilder.java @@ -1,42 +1,42 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.ParameterManager; -import com.blazebit.persistence.impl.SubqueryInitiatorFactory; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.impl.predicate.PredicateQuantifier; -import com.blazebit.persistence.impl.predicate.EqPredicate; -import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; - -/** - * - * @author Moritz Becker - */ -public class EqPredicateBuilder extends AbstractQuantifiablePredicateBuilder { - - public EqPredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, boolean wrapNot, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { - super(result, listener, leftExpression, wrapNot, subqueryInitFactory, expressionFactory, parameterManager); - } - - @Override - protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - return new EqPredicate(left, right, quantifier); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.ParameterManager; +import com.blazebit.persistence.impl.SubqueryInitiatorFactory; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.impl.predicate.PredicateQuantifier; +import com.blazebit.persistence.impl.predicate.EqPredicate; +import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; + +/** + * + * @author Moritz Becker + */ +public class EqPredicateBuilder extends AbstractQuantifiablePredicateBuilder { + + public EqPredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, boolean wrapNot, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { + super(result, listener, leftExpression, wrapNot, subqueryInitFactory, expressionFactory, parameterManager); + } + + @Override + protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + return new EqPredicate(left, right, quantifier); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/GePredicateBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/GePredicateBuilder.java index c3fa32689a..edb9e25aec 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/GePredicateBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/GePredicateBuilder.java @@ -1,42 +1,42 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.ParameterManager; -import com.blazebit.persistence.impl.SubqueryInitiatorFactory; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.impl.predicate.PredicateQuantifier; -import com.blazebit.persistence.impl.predicate.GePredicate; -import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; - -/** - * - * @author Moritz Becker - */ -public class GePredicateBuilder extends AbstractQuantifiablePredicateBuilder { - - public GePredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { - super(result, listener, leftExpression, false, subqueryInitFactory, expressionFactory, parameterManager); - } - - @Override - protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - return new GePredicate(left, right, quantifier); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.ParameterManager; +import com.blazebit.persistence.impl.SubqueryInitiatorFactory; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.impl.predicate.PredicateQuantifier; +import com.blazebit.persistence.impl.predicate.GePredicate; +import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; + +/** + * + * @author Moritz Becker + */ +public class GePredicateBuilder extends AbstractQuantifiablePredicateBuilder { + + public GePredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { + super(result, listener, leftExpression, false, subqueryInitFactory, expressionFactory, parameterManager); + } + + @Override + protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + return new GePredicate(left, right, quantifier); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/GtPredicateBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/GtPredicateBuilder.java index c3c4620d88..b05e86876c 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/GtPredicateBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/GtPredicateBuilder.java @@ -1,42 +1,42 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.ParameterManager; -import com.blazebit.persistence.impl.SubqueryInitiatorFactory; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.impl.predicate.PredicateQuantifier; -import com.blazebit.persistence.impl.predicate.GtPredicate; -import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; - -/** - * - * @author Moritz Becker - */ -public class GtPredicateBuilder extends AbstractQuantifiablePredicateBuilder { - - public GtPredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { - super(result, listener, leftExpression, false, subqueryInitFactory, expressionFactory, parameterManager); - } - - @Override - protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - return new GtPredicate(left, right, quantifier); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.ParameterManager; +import com.blazebit.persistence.impl.SubqueryInitiatorFactory; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.impl.predicate.PredicateQuantifier; +import com.blazebit.persistence.impl.predicate.GtPredicate; +import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; + +/** + * + * @author Moritz Becker + */ +public class GtPredicateBuilder extends AbstractQuantifiablePredicateBuilder { + + public GtPredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { + super(result, listener, leftExpression, false, subqueryInitFactory, expressionFactory, parameterManager); + } + + @Override + protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + return new GtPredicate(left, right, quantifier); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LePredicateBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LePredicateBuilder.java index a5dd736615..7823d17508 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LePredicateBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LePredicateBuilder.java @@ -1,42 +1,42 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.ParameterManager; -import com.blazebit.persistence.impl.SubqueryInitiatorFactory; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.impl.predicate.PredicateQuantifier; -import com.blazebit.persistence.impl.predicate.LePredicate; -import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; - -/** - * - * @author Moritz Becker - */ -public class LePredicateBuilder extends AbstractQuantifiablePredicateBuilder { - - public LePredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { - super(result, listener, leftExpression, false, subqueryInitFactory, expressionFactory, parameterManager); - } - - @Override - protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - return new LePredicate(left, right, quantifier); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.ParameterManager; +import com.blazebit.persistence.impl.SubqueryInitiatorFactory; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.impl.predicate.PredicateQuantifier; +import com.blazebit.persistence.impl.predicate.LePredicate; +import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; + +/** + * + * @author Moritz Becker + */ +public class LePredicateBuilder extends AbstractQuantifiablePredicateBuilder { + + public LePredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { + super(result, listener, leftExpression, false, subqueryInitFactory, expressionFactory, parameterManager); + } + + @Override + protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + return new LePredicate(left, right, quantifier); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LeftHandsideSubqueryPredicateBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LeftHandsideSubqueryPredicateBuilder.java index 7f4cdbf4d1..13cdad3692 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LeftHandsideSubqueryPredicateBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LeftHandsideSubqueryPredicateBuilder.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.predicate.PredicateBuilder; - -/** - * - * @author Moritz Becker - */ -public interface LeftHandsideSubqueryPredicateBuilder extends PredicateBuilder { - - public void setLeftExpression(Expression left); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.predicate.PredicateBuilder; + +/** + * + * @author Moritz Becker + */ +public interface LeftHandsideSubqueryPredicateBuilder extends PredicateBuilder { + + public void setLeftExpression(Expression left); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LeftHandsideSubqueryPredicateBuilderListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LeftHandsideSubqueryPredicateBuilderListener.java index 9e162951de..ff4cb1455b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LeftHandsideSubqueryPredicateBuilderListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LeftHandsideSubqueryPredicateBuilderListener.java @@ -1,35 +1,35 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.SubqueryBuilderListenerImpl; -import com.blazebit.persistence.impl.SubqueryInternalBuilder; -import com.blazebit.persistence.impl.expression.SubqueryExpression; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class LeftHandsideSubqueryPredicateBuilderListener extends SubqueryBuilderListenerImpl { - - @Override - public void onBuilderEnded(SubqueryInternalBuilder builder) { - super.onBuilderEnded(builder); - T leftHandsideSubqueryPredicateBuilder = builder.getResult(); - leftHandsideSubqueryPredicateBuilder.setLeftExpression(new SubqueryExpression(builder)); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.SubqueryBuilderListenerImpl; +import com.blazebit.persistence.impl.SubqueryInternalBuilder; +import com.blazebit.persistence.impl.expression.SubqueryExpression; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class LeftHandsideSubqueryPredicateBuilderListener extends SubqueryBuilderListenerImpl { + + @Override + public void onBuilderEnded(SubqueryInternalBuilder builder) { + super.onBuilderEnded(builder); + T leftHandsideSubqueryPredicateBuilder = builder.getResult(); + leftHandsideSubqueryPredicateBuilder.setLeftExpression(new SubqueryExpression(builder)); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LtPredicateBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LtPredicateBuilder.java index 1159039096..894c36840f 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LtPredicateBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/LtPredicateBuilder.java @@ -1,42 +1,42 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.ParameterManager; -import com.blazebit.persistence.impl.SubqueryInitiatorFactory; -import com.blazebit.persistence.impl.expression.Expression; -import com.blazebit.persistence.impl.expression.ExpressionFactory; -import com.blazebit.persistence.impl.predicate.PredicateQuantifier; -import com.blazebit.persistence.impl.predicate.LtPredicate; -import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; - -/** - * - * @author Moritz Becker - */ -public class LtPredicateBuilder extends AbstractQuantifiablePredicateBuilder { - - public LtPredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { - super(result, listener, leftExpression, false, subqueryInitFactory, expressionFactory, parameterManager); - } - - @Override - protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - return new LtPredicate(left, right, quantifier); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.ParameterManager; +import com.blazebit.persistence.impl.SubqueryInitiatorFactory; +import com.blazebit.persistence.impl.expression.Expression; +import com.blazebit.persistence.impl.expression.ExpressionFactory; +import com.blazebit.persistence.impl.predicate.PredicateQuantifier; +import com.blazebit.persistence.impl.predicate.LtPredicate; +import com.blazebit.persistence.impl.predicate.QuantifiableBinaryExpressionPredicate; + +/** + * + * @author Moritz Becker + */ +public class LtPredicateBuilder extends AbstractQuantifiablePredicateBuilder { + + public LtPredicateBuilder(T result, PredicateBuilderEndedListener listener, Expression leftExpression, SubqueryInitiatorFactory subqueryInitFactory, ExpressionFactory expressionFactory, ParameterManager parameterManager) { + super(result, listener, leftExpression, false, subqueryInitFactory, expressionFactory, parameterManager); + } + + @Override + protected QuantifiableBinaryExpressionPredicate createPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + return new LtPredicate(left, right, quantifier); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/PredicateBuilderEndedListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/PredicateBuilderEndedListener.java index 8863b9f8be..d3d2f8f86e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/PredicateBuilderEndedListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/PredicateBuilderEndedListener.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.predicate.PredicateBuilder; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public interface PredicateBuilderEndedListener { - - public void onBuilderEnded(PredicateBuilder o); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.predicate.PredicateBuilder; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public interface PredicateBuilderEndedListener { + + public void onBuilderEnded(PredicateBuilder o); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/PredicateBuilderEndedListenerImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/PredicateBuilderEndedListenerImpl.java index 4c1292a9dc..7d9acb0bce 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/PredicateBuilderEndedListenerImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/PredicateBuilderEndedListenerImpl.java @@ -1,54 +1,54 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.BuilderChainingException; -import com.blazebit.persistence.impl.predicate.PredicateBuilder; - -/** - * A base class that provides functionality to start and stop builders in a manner, such that only one builder can be started at a time. - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class PredicateBuilderEndedListenerImpl implements PredicateBuilderEndedListener { - - private PredicateBuilder currentBuilder; - - public void verifyBuilderEnded() { - if (currentBuilder != null) { - throw new BuilderChainingException("A builder was not ended properly."); - } - } - - public T startBuilder(T builder) { - if (currentBuilder != null) { - throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); - } - - currentBuilder = builder; - return builder; - } - - @Override - public void onBuilderEnded(PredicateBuilder builder) { - if (currentBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - currentBuilder = null; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.BuilderChainingException; +import com.blazebit.persistence.impl.predicate.PredicateBuilder; + +/** + * A base class that provides functionality to start and stop builders in a manner, such that only one builder can be started at a time. + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class PredicateBuilderEndedListenerImpl implements PredicateBuilderEndedListener { + + private PredicateBuilder currentBuilder; + + public void verifyBuilderEnded() { + if (currentBuilder != null) { + throw new BuilderChainingException("A builder was not ended properly."); + } + } + + public T startBuilder(T builder) { + if (currentBuilder != null) { + throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); + } + + currentBuilder = builder; + return builder; + } + + @Override + public void onBuilderEnded(PredicateBuilder builder) { + if (currentBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + currentBuilder = null; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/SuperExpressionLeftHandsideSubqueryPredicateBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/SuperExpressionLeftHandsideSubqueryPredicateBuilder.java index fb3f1efa99..0a86ead7f2 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/SuperExpressionLeftHandsideSubqueryPredicateBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/builder/predicate/SuperExpressionLeftHandsideSubqueryPredicateBuilder.java @@ -1,39 +1,39 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.builder.predicate; - -import com.blazebit.persistence.impl.SubqueryInternalBuilder; -import com.blazebit.persistence.impl.builder.expression.SuperExpressionSubqueryBuilderListener; -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class SuperExpressionLeftHandsideSubqueryPredicateBuilder extends SuperExpressionSubqueryBuilderListener { - - public SuperExpressionLeftHandsideSubqueryPredicateBuilder(String subqueryAlias, Expression superExpression) { - super(subqueryAlias, superExpression); - } - - @Override - public void onBuilderEnded(SubqueryInternalBuilder builder) { - super.onBuilderEnded(builder); - LeftHandsideSubqueryPredicateBuilder leftHandsideSubqueryPredicateBuilder = (LeftHandsideSubqueryPredicateBuilder) builder.getResult(); - leftHandsideSubqueryPredicateBuilder.setLeftExpression(superExpression); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.builder.predicate; + +import com.blazebit.persistence.impl.SubqueryInternalBuilder; +import com.blazebit.persistence.impl.builder.expression.SuperExpressionSubqueryBuilderListener; +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class SuperExpressionLeftHandsideSubqueryPredicateBuilder extends SuperExpressionSubqueryBuilderListener { + + public SuperExpressionLeftHandsideSubqueryPredicateBuilder(String subqueryAlias, Expression superExpression) { + super(subqueryAlias, superExpression); + } + + @Override + public void onBuilderEnded(SubqueryInternalBuilder builder) { + super.onBuilderEnded(builder); + LeftHandsideSubqueryPredicateBuilder leftHandsideSubqueryPredicateBuilder = (LeftHandsideSubqueryPredicateBuilder) builder.getResult(); + leftHandsideSubqueryPredicateBuilder.setLeftExpression(superExpression); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/dialect/MySQLDbmsDialect.java b/core/impl/src/main/java/com/blazebit/persistence/impl/dialect/MySQLDbmsDialect.java index b4c9f280b4..3cdf7e7c5c 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/dialect/MySQLDbmsDialect.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/dialect/MySQLDbmsDialect.java @@ -1,77 +1,77 @@ -package com.blazebit.persistence.impl.dialect; - -import com.blazebit.persistence.impl.function.CyclicUnsignedCounter; -import com.blazebit.persistence.spi.OrderByElement; - -public class MySQLDbmsDialect extends DefaultDbmsDialect { - - private static final ThreadLocal threadLocalCounter = new ThreadLocal() { - - @Override - protected CyclicUnsignedCounter initialValue() { - return new CyclicUnsignedCounter(-1); - } - - }; - - @Override - public boolean supportsWithClause() { - return false; - } - - @Override - public boolean supportsNonRecursiveWithClause() { - return false; - } - - @Override - public String getWithClause(boolean recursive) { - throw new UnsupportedOperationException("With clause is not supported!"); - } - - @Override - public boolean supportsUnion(boolean all) { - return true; - } - - @Override - public boolean supportsIntersect(boolean all) { - return false; - } - - @Override - public boolean supportsExcept(boolean all) { - return false; - } - - /** - * Uses a workaround for limit in IN predicates because of an limitation of MySQL. - * See http://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html for reference. - * - */ - @Override - public void appendLimit(StringBuilder sqlSb, boolean isSubquery, String limit, String offset) { - if (isSubquery) { - // Insert it after the open bracket - sqlSb.insert(1, "SELECT * FROM ("); - } - - if (offset == null) { - sqlSb.append(" limit ").append(limit); - } else { - // NOTE: this requires that the parameter value is pulled into the query as literal - sqlSb.append(" limit ").append(offset).append(',').append(limit); - } - - if (isSubquery) { - String limitSubqueryAlias = "_tmp_" + threadLocalCounter.get().incrementAndGet(); - sqlSb.append(") as ").append(limitSubqueryAlias); - } - } - - @Override - protected void appendOrderByElement(StringBuilder sqlSb, OrderByElement element) { - appendEmulatedOrderByElementWithNulls(sqlSb, element); - } - -} +package com.blazebit.persistence.impl.dialect; + +import com.blazebit.persistence.impl.function.CyclicUnsignedCounter; +import com.blazebit.persistence.spi.OrderByElement; + +public class MySQLDbmsDialect extends DefaultDbmsDialect { + + private static final ThreadLocal threadLocalCounter = new ThreadLocal() { + + @Override + protected CyclicUnsignedCounter initialValue() { + return new CyclicUnsignedCounter(-1); + } + + }; + + @Override + public boolean supportsWithClause() { + return false; + } + + @Override + public boolean supportsNonRecursiveWithClause() { + return false; + } + + @Override + public String getWithClause(boolean recursive) { + throw new UnsupportedOperationException("With clause is not supported!"); + } + + @Override + public boolean supportsUnion(boolean all) { + return true; + } + + @Override + public boolean supportsIntersect(boolean all) { + return false; + } + + @Override + public boolean supportsExcept(boolean all) { + return false; + } + + /** + * Uses a workaround for limit in IN predicates because of an limitation of MySQL. + * See http://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html for reference. + * + */ + @Override + public void appendLimit(StringBuilder sqlSb, boolean isSubquery, String limit, String offset) { + if (isSubquery) { + // Insert it after the open bracket + sqlSb.insert(1, "SELECT * FROM ("); + } + + if (offset == null) { + sqlSb.append(" limit ").append(limit); + } else { + // NOTE: this requires that the parameter value is pulled into the query as literal + sqlSb.append(" limit ").append(offset).append(',').append(limit); + } + + if (isSubquery) { + String limitSubqueryAlias = "_tmp_" + threadLocalCounter.get().incrementAndGet(); + sqlSb.append(") as ").append(limitSubqueryAlias); + } + } + + @Override + protected void appendOrderByElement(StringBuilder sqlSb, OrderByElement element) { + appendEmulatedOrderByElementWithNulls(sqlSb, element); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/dialect/PostgreSQLDbmsDialect.java b/core/impl/src/main/java/com/blazebit/persistence/impl/dialect/PostgreSQLDbmsDialect.java index 3a02857954..c3160d05c7 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/dialect/PostgreSQLDbmsDialect.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/dialect/PostgreSQLDbmsDialect.java @@ -1,168 +1,168 @@ -package com.blazebit.persistence.impl.dialect; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import com.blazebit.persistence.spi.DbmsModificationState; -import com.blazebit.persistence.spi.DbmsStatementType; - -public class PostgreSQLDbmsDialect extends DefaultDbmsDialect { - - @Override - public boolean supportsModificationQueryInWithClause() { - return true; - } - - @Override - public boolean supportsReturningColumns() { - return true; - } - - @Override - public Map appendExtendedSql(StringBuilder sqlSb, DbmsStatementType statementType, boolean isSubquery, boolean isEmbedded, StringBuilder withClause, String limit, String offset, String[] returningColumns, Map includedModificationStates) { - // since changes in PostgreSQL won't be visible to other queries, we need to create the new state if required - boolean requiresNew = includedModificationStates != null && includedModificationStates.containsKey(DbmsModificationState.NEW); - - if (requiresNew) { - StringBuilder sb = new StringBuilder(sqlSb.length() + returningColumns.length * 30); - sb.append(sqlSb); - sb.append(" returning *"); - - sqlSb.setLength(0); - - if (isSubquery) { - sqlSb.append('('); - } - - if (statementType == DbmsStatementType.DELETE) { - appendSelectColumnsFromTable(statementType, sb, sqlSb, returningColumns); - sqlSb.append("\nexcept\n"); - appendSelectColumnsFromCte(sqlSb, returningColumns, includedModificationStates); - } else { - appendSelectColumnsFromCte(sqlSb, returningColumns, includedModificationStates); - sqlSb.append("\nunion\n"); - appendSelectColumnsFromTable(statementType, sb, sqlSb, returningColumns); - } - - if (isSubquery) { - sqlSb.append(')'); - } - - return Collections.singletonMap(includedModificationStates.get(DbmsModificationState.NEW), sb.toString()); - } - - if (isSubquery) { - sqlSb.insert(0, '('); - } - - if (withClause != null) { - sqlSb.insert(0, withClause); - } - if (limit != null) { - appendLimit(sqlSb, isSubquery, limit, offset); - } - - if (isEmbedded && returningColumns != null) { - sqlSb.append(" returning "); - - for (int i = 0; i < returningColumns.length; i++) { - if (i != 0) { - sqlSb.append(","); - } - - sqlSb.append(returningColumns[i]); - } - } - - if (isSubquery) { - sqlSb.append(')'); - } - - return null; - } - - @Override - protected void appendSetOperands(StringBuilder sqlSb, String operator, boolean isSubquery, List operands, boolean hasOuterClause) { - boolean first = true; - for (String operand : operands) { - if (first) { - first = false; - } else { - sqlSb.append("\n"); - sqlSb.append(operator); - sqlSb.append("\n"); - } - - if (hasOuterClause && !operand.startsWith("(")) { - // Wrap operand so that the order by or limit has a clear target - sqlSb.append('('); - sqlSb.append(operand); - sqlSb.append(')'); - } else { - sqlSb.append(operand); - } - } - } - - private static void appendSelectColumnsFromCte(StringBuilder sqlSb, String[] returningColumns, Map includedModificationStates) { - sqlSb.append("select "); - for (int i = 0; i < returningColumns.length; i++) { - if (i != 0) { - sqlSb.append(","); - } - - sqlSb.append(returningColumns[i]); - } - - sqlSb.append(" from "); - sqlSb.append(includedModificationStates.get(DbmsModificationState.NEW)); - } - - private static void appendSelectColumnsFromTable(DbmsStatementType statementType, StringBuilder sb, StringBuilder sqlSb, String[] returningColumns) { - String table; - if (statementType == DbmsStatementType.DELETE) { - String needle = "from"; - int startIndex = indexOfIgnoreCase(sb, needle) + needle.length() + 1; - int endIndex = sb.indexOf(" ", startIndex); - table = sb.substring(startIndex, endIndex); - } else if (statementType == DbmsStatementType.UPDATE) { - String needle = "update"; - int startIndex = indexOfIgnoreCase(sb, needle) + needle.length() + 1; - int endIndex = sb.indexOf(" ", startIndex); - table = sb.substring(startIndex, endIndex); - } else if (statementType == DbmsStatementType.INSERT) { - String needle = "into"; - int startIndex = indexOfIgnoreCase(sb, needle) + needle.length() + 1; - int endIndex = sb.indexOf(" ", startIndex); - endIndex = indexOfOrEnd(sb, '(', startIndex, endIndex); - table = sb.substring(startIndex, endIndex); - } else { - throw new IllegalArgumentException("Unsupported statement type: " + statementType); - } - - sqlSb.append(" select "); - for (int i = 0; i < returningColumns.length; i++) { - if (i != 0) { - sqlSb.append(","); - } - - sqlSb.append(returningColumns[i]); - } - sqlSb.append(" from "); - sqlSb.append(table); - } - - private static int indexOfOrEnd(StringBuilder sb, char needle, int startIndex, int endIndex) { - while (startIndex < endIndex) { - if (sb.charAt(startIndex) == needle) { - return startIndex; - } - - startIndex++; - } - - return endIndex; - } - -} +package com.blazebit.persistence.impl.dialect; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.blazebit.persistence.spi.DbmsModificationState; +import com.blazebit.persistence.spi.DbmsStatementType; + +public class PostgreSQLDbmsDialect extends DefaultDbmsDialect { + + @Override + public boolean supportsModificationQueryInWithClause() { + return true; + } + + @Override + public boolean supportsReturningColumns() { + return true; + } + + @Override + public Map appendExtendedSql(StringBuilder sqlSb, DbmsStatementType statementType, boolean isSubquery, boolean isEmbedded, StringBuilder withClause, String limit, String offset, String[] returningColumns, Map includedModificationStates) { + // since changes in PostgreSQL won't be visible to other queries, we need to create the new state if required + boolean requiresNew = includedModificationStates != null && includedModificationStates.containsKey(DbmsModificationState.NEW); + + if (requiresNew) { + StringBuilder sb = new StringBuilder(sqlSb.length() + returningColumns.length * 30); + sb.append(sqlSb); + sb.append(" returning *"); + + sqlSb.setLength(0); + + if (isSubquery) { + sqlSb.append('('); + } + + if (statementType == DbmsStatementType.DELETE) { + appendSelectColumnsFromTable(statementType, sb, sqlSb, returningColumns); + sqlSb.append("\nexcept\n"); + appendSelectColumnsFromCte(sqlSb, returningColumns, includedModificationStates); + } else { + appendSelectColumnsFromCte(sqlSb, returningColumns, includedModificationStates); + sqlSb.append("\nunion\n"); + appendSelectColumnsFromTable(statementType, sb, sqlSb, returningColumns); + } + + if (isSubquery) { + sqlSb.append(')'); + } + + return Collections.singletonMap(includedModificationStates.get(DbmsModificationState.NEW), sb.toString()); + } + + if (isSubquery) { + sqlSb.insert(0, '('); + } + + if (withClause != null) { + sqlSb.insert(0, withClause); + } + if (limit != null) { + appendLimit(sqlSb, isSubquery, limit, offset); + } + + if (isEmbedded && returningColumns != null) { + sqlSb.append(" returning "); + + for (int i = 0; i < returningColumns.length; i++) { + if (i != 0) { + sqlSb.append(","); + } + + sqlSb.append(returningColumns[i]); + } + } + + if (isSubquery) { + sqlSb.append(')'); + } + + return null; + } + + @Override + protected void appendSetOperands(StringBuilder sqlSb, String operator, boolean isSubquery, List operands, boolean hasOuterClause) { + boolean first = true; + for (String operand : operands) { + if (first) { + first = false; + } else { + sqlSb.append("\n"); + sqlSb.append(operator); + sqlSb.append("\n"); + } + + if (hasOuterClause && !operand.startsWith("(")) { + // Wrap operand so that the order by or limit has a clear target + sqlSb.append('('); + sqlSb.append(operand); + sqlSb.append(')'); + } else { + sqlSb.append(operand); + } + } + } + + private static void appendSelectColumnsFromCte(StringBuilder sqlSb, String[] returningColumns, Map includedModificationStates) { + sqlSb.append("select "); + for (int i = 0; i < returningColumns.length; i++) { + if (i != 0) { + sqlSb.append(","); + } + + sqlSb.append(returningColumns[i]); + } + + sqlSb.append(" from "); + sqlSb.append(includedModificationStates.get(DbmsModificationState.NEW)); + } + + private static void appendSelectColumnsFromTable(DbmsStatementType statementType, StringBuilder sb, StringBuilder sqlSb, String[] returningColumns) { + String table; + if (statementType == DbmsStatementType.DELETE) { + String needle = "from"; + int startIndex = indexOfIgnoreCase(sb, needle) + needle.length() + 1; + int endIndex = sb.indexOf(" ", startIndex); + table = sb.substring(startIndex, endIndex); + } else if (statementType == DbmsStatementType.UPDATE) { + String needle = "update"; + int startIndex = indexOfIgnoreCase(sb, needle) + needle.length() + 1; + int endIndex = sb.indexOf(" ", startIndex); + table = sb.substring(startIndex, endIndex); + } else if (statementType == DbmsStatementType.INSERT) { + String needle = "into"; + int startIndex = indexOfIgnoreCase(sb, needle) + needle.length() + 1; + int endIndex = sb.indexOf(" ", startIndex); + endIndex = indexOfOrEnd(sb, '(', startIndex, endIndex); + table = sb.substring(startIndex, endIndex); + } else { + throw new IllegalArgumentException("Unsupported statement type: " + statementType); + } + + sqlSb.append(" select "); + for (int i = 0; i < returningColumns.length; i++) { + if (i != 0) { + sqlSb.append(","); + } + + sqlSb.append(returningColumns[i]); + } + sqlSb.append(" from "); + sqlSb.append(table); + } + + private static int indexOfOrEnd(StringBuilder sb, char needle, int startIndex, int endIndex) { + while (startIndex < endIndex) { + if (sb.charAt(startIndex) == needle) { + return startIndex; + } + + startIndex++; + } + + return endIndex; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/CyclicUnsignedCounter.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/CyclicUnsignedCounter.java index c2b3f09483..e6ffd46375 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/CyclicUnsignedCounter.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/CyclicUnsignedCounter.java @@ -1,23 +1,23 @@ -package com.blazebit.persistence.impl.function; - -public class CyclicUnsignedCounter { - - private int value = Integer.MIN_VALUE; - - public CyclicUnsignedCounter() { - } - - public CyclicUnsignedCounter(int value) { - this.value = value; - } - - public int incrementAndGet() { - return value = (value + 1) & Integer.MAX_VALUE; - } - - public int getAndIncrement() { - int temp = value; - value = (value + 1) & Integer.MAX_VALUE; - return temp; - } -} +package com.blazebit.persistence.impl.function; + +public class CyclicUnsignedCounter { + + private int value = Integer.MIN_VALUE; + + public CyclicUnsignedCounter() { + } + + public CyclicUnsignedCounter(int value) { + this.value = value; + } + + public int incrementAndGet() { + return value = (value + 1) & Integer.MAX_VALUE; + } + + public int getAndIncrement() { + int temp = value; + value = (value + 1) & Integer.MAX_VALUE; + return temp; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/DateDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/DateDiffFunction.java index e86f507b91..4027304c95 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/DateDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/DateDiffFunction.java @@ -1,63 +1,63 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff; - -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.TemplateRenderer; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class DateDiffFunction implements JpqlFunction { - - private final String functionName; - protected final TemplateRenderer renderer; - - public DateDiffFunction(String functionName, String template) { - this.functionName = functionName; - this.renderer = new TemplateRenderer(template); - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return Integer.class; - } - - @Override - public void render(FunctionRenderContext context) { - if (context.getArgumentsSize() != 2) { - throw new RuntimeException("The " + functionName + " function needs exactly two arguments and ! args=" + context); - } - - renderDiff(context); - } - - protected abstract void renderDiff(FunctionRenderContext context); - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.TemplateRenderer; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class DateDiffFunction implements JpqlFunction { + + private final String functionName; + protected final TemplateRenderer renderer; + + public DateDiffFunction(String functionName, String template) { + this.functionName = functionName; + this.renderer = new TemplateRenderer(template); + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return Integer.class; + } + + @Override + public void render(FunctionRenderContext context) { + if (context.getArgumentsSize() != 2) { + throw new RuntimeException("The " + functionName + " function needs exactly two arguments and ! args=" + context); + } + + renderDiff(context); + } + + protected abstract void renderDiff(FunctionRenderContext context); + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/AccessDayDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/AccessDayDiffFunction.java index 0086de2d10..c689a4ed93 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/AccessDayDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/AccessDayDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.day; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessDayDiffFunction extends DayDiffFunction { - - public AccessDayDiffFunction() { - super("DateDiff('d', ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.day; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessDayDiffFunction extends DayDiffFunction { + + public AccessDayDiffFunction() { + super("DateDiff('d', ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/DayDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/DayDiffFunction.java index 2c6910d6bd..182c6f21ef 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/DayDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/DayDiffFunction.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.day; - -import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class DayDiffFunction extends DateDiffFunction { - - public DayDiffFunction(String template) { - super("day_diff", template); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.day; + +import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class DayDiffFunction extends DateDiffFunction { + + public DayDiffFunction(String template) { + super("day_diff", template); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/DefaultDayDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/DefaultDayDiffFunction.java index 272a22e547..2ab09fadcf 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/DefaultDayDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/DefaultDayDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.day; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DefaultDayDiffFunction extends DayDiffFunction { - - public DefaultDayDiffFunction() { - super("datediff(dd, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.day; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DefaultDayDiffFunction extends DayDiffFunction { + + public DefaultDayDiffFunction() { + super("datediff(dd, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/MySQLDayDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/MySQLDayDiffFunction.java index 4c4bcec11d..55c54c7f91 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/MySQLDayDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/day/MySQLDayDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.day; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MySQLDayDiffFunction extends DayDiffFunction { - - public MySQLDayDiffFunction() { - super("timestampdiff(DAY, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.day; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MySQLDayDiffFunction extends DayDiffFunction { + + public MySQLDayDiffFunction() { + super("timestampdiff(DAY, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/AccessHourDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/AccessHourDiffFunction.java index e22fc55a4e..f43a04aca1 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/AccessHourDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/AccessHourDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.hour; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessHourDiffFunction extends HourDiffFunction { - - public AccessHourDiffFunction() { - super("DateDiff('h', ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.hour; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessHourDiffFunction extends HourDiffFunction { + + public AccessHourDiffFunction() { + super("DateDiff('h', ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/DefaultHourDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/DefaultHourDiffFunction.java index 12408a6baf..e6ae30c582 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/DefaultHourDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/DefaultHourDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.hour; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DefaultHourDiffFunction extends HourDiffFunction { - - public DefaultHourDiffFunction() { - super("datediff(hh, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.hour; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DefaultHourDiffFunction extends HourDiffFunction { + + public DefaultHourDiffFunction() { + super("datediff(hh, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/HourDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/HourDiffFunction.java index 1095f376fb..3471d249b0 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/HourDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/HourDiffFunction.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.hour; - -import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class HourDiffFunction extends DateDiffFunction { - - public HourDiffFunction(String template) { - super("hour_diff", template); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.hour; + +import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class HourDiffFunction extends DateDiffFunction { + + public HourDiffFunction(String template) { + super("hour_diff", template); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/MySQLHourDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/MySQLHourDiffFunction.java index 5bab8bd4ef..0bb7055928 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/MySQLHourDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/hour/MySQLHourDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.hour; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MySQLHourDiffFunction extends HourDiffFunction { - - public MySQLHourDiffFunction() { - super("timestampdiff(HOUR, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.hour; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MySQLHourDiffFunction extends HourDiffFunction { + + public MySQLHourDiffFunction() { + super("timestampdiff(HOUR, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/AccessMinuteDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/AccessMinuteDiffFunction.java index f077734fec..1a02a5ba40 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/AccessMinuteDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/AccessMinuteDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.minute; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessMinuteDiffFunction extends MinuteDiffFunction { - - public AccessMinuteDiffFunction() { - super("DateDiff('n', ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.minute; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessMinuteDiffFunction extends MinuteDiffFunction { + + public AccessMinuteDiffFunction() { + super("DateDiff('n', ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/DefaultMinuteDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/DefaultMinuteDiffFunction.java index e46f8e0c42..02712107b3 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/DefaultMinuteDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/DefaultMinuteDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.minute; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DefaultMinuteDiffFunction extends MinuteDiffFunction { - - public DefaultMinuteDiffFunction() { - super("datediff(mi, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.minute; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DefaultMinuteDiffFunction extends MinuteDiffFunction { + + public DefaultMinuteDiffFunction() { + super("datediff(mi, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/MinuteDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/MinuteDiffFunction.java index 38dd9ba0ef..9f5b7f05bd 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/MinuteDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/MinuteDiffFunction.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.minute; - -import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class MinuteDiffFunction extends DateDiffFunction { - - public MinuteDiffFunction(String template) { - super("minute_diff", template); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.minute; + +import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class MinuteDiffFunction extends DateDiffFunction { + + public MinuteDiffFunction(String template) { + super("minute_diff", template); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/MySQLMinuteDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/MySQLMinuteDiffFunction.java index b14f5bec39..573ec646f7 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/MySQLMinuteDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/minute/MySQLMinuteDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.minute; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MySQLMinuteDiffFunction extends MinuteDiffFunction { - - public MySQLMinuteDiffFunction() { - super("timestampdiff(MINUTE, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.minute; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MySQLMinuteDiffFunction extends MinuteDiffFunction { + + public MySQLMinuteDiffFunction() { + super("timestampdiff(MINUTE, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/AccessMonthDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/AccessMonthDiffFunction.java index e3556e9d06..6bd2a424e3 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/AccessMonthDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/AccessMonthDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.month; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessMonthDiffFunction extends MonthDiffFunction { - - public AccessMonthDiffFunction() { - super("DateDiff('m', ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.month; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessMonthDiffFunction extends MonthDiffFunction { + + public AccessMonthDiffFunction() { + super("DateDiff('m', ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/DefaultMonthDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/DefaultMonthDiffFunction.java index ffbefd8400..243aa75512 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/DefaultMonthDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/DefaultMonthDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.month; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DefaultMonthDiffFunction extends MonthDiffFunction { - - public DefaultMonthDiffFunction() { - super("datediff(mm, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.month; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DefaultMonthDiffFunction extends MonthDiffFunction { + + public DefaultMonthDiffFunction() { + super("datediff(mm, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/MonthDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/MonthDiffFunction.java index 814c125c05..cda345c330 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/MonthDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/MonthDiffFunction.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.month; - -import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class MonthDiffFunction extends DateDiffFunction { - - public MonthDiffFunction(String template) { - super("month_diff", template); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.month; + +import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class MonthDiffFunction extends DateDiffFunction { + + public MonthDiffFunction(String template) { + super("month_diff", template); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/MySQLMonthDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/MySQLMonthDiffFunction.java index a6f99fde1c..7766bed458 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/MySQLMonthDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/month/MySQLMonthDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.month; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MySQLMonthDiffFunction extends MonthDiffFunction { - - public MySQLMonthDiffFunction() { - super("timestampdiff(MONTH, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.month; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MySQLMonthDiffFunction extends MonthDiffFunction { + + public MySQLMonthDiffFunction() { + super("timestampdiff(MONTH, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/AccessSecondDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/AccessSecondDiffFunction.java index d4eb58f6d9..edca9a4c34 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/AccessSecondDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/AccessSecondDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.second; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessSecondDiffFunction extends SecondDiffFunction { - - public AccessSecondDiffFunction() { - super("DateDiff('s', ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.second; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessSecondDiffFunction extends SecondDiffFunction { + + public AccessSecondDiffFunction() { + super("DateDiff('s', ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/DefaultSecondDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/DefaultSecondDiffFunction.java index a70db5a0c0..c07859b83e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/DefaultSecondDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/DefaultSecondDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.second; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DefaultSecondDiffFunction extends SecondDiffFunction { - - public DefaultSecondDiffFunction() { - super("datediff(ss, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.second; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DefaultSecondDiffFunction extends SecondDiffFunction { + + public DefaultSecondDiffFunction() { + super("datediff(ss, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/MySQLSecondDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/MySQLSecondDiffFunction.java index 5dc065f188..e8a78940e0 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/MySQLSecondDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/MySQLSecondDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.second; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MySQLSecondDiffFunction extends SecondDiffFunction { - - public MySQLSecondDiffFunction() { - super("timestampdiff(SECOND, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.second; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MySQLSecondDiffFunction extends SecondDiffFunction { + + public MySQLSecondDiffFunction() { + super("timestampdiff(SECOND, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/SecondDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/SecondDiffFunction.java index ddd880e6c8..57d4cf695b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/SecondDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/second/SecondDiffFunction.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.second; - -import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class SecondDiffFunction extends DateDiffFunction { - - public SecondDiffFunction(String template) { - super("second_diff", template); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.second; + +import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class SecondDiffFunction extends DateDiffFunction { + + public SecondDiffFunction(String template) { + super("second_diff", template); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/AccessYearDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/AccessYearDiffFunction.java index 81e5e60a96..f7b5a4cc3a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/AccessYearDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/AccessYearDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.year; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessYearDiffFunction extends YearDiffFunction { - - public AccessYearDiffFunction() { - super("DateDiff('yyyy', ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.year; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessYearDiffFunction extends YearDiffFunction { + + public AccessYearDiffFunction() { + super("DateDiff('yyyy', ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/DefaultYearDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/DefaultYearDiffFunction.java index ff3c9c6934..3e328472ba 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/DefaultYearDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/DefaultYearDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.year; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DefaultYearDiffFunction extends YearDiffFunction { - - public DefaultYearDiffFunction() { - super("datediff(yy, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.year; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DefaultYearDiffFunction extends YearDiffFunction { + + public DefaultYearDiffFunction() { + super("datediff(yy, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/MySQLYearDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/MySQLYearDiffFunction.java index a64ae0e203..61800198f9 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/MySQLYearDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/MySQLYearDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.year; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MySQLYearDiffFunction extends YearDiffFunction { - - public MySQLYearDiffFunction() { - super("timestampdiff(YEAR, ?1, ?2)"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.year; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MySQLYearDiffFunction extends YearDiffFunction { + + public MySQLYearDiffFunction() { + super("timestampdiff(YEAR, ?1, ?2)"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/PostgreSQLYearDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/PostgreSQLYearDiffFunction.java index ae0c555d9c..603f175269 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/PostgreSQLYearDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/PostgreSQLYearDiffFunction.java @@ -1,35 +1,35 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.year; - -import com.blazebit.persistence.spi.FunctionRenderContext; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class PostgreSQLYearDiffFunction extends YearDiffFunction { - - public PostgreSQLYearDiffFunction() { - super("(select date_part('year', t2) - date_part('year', t1) from (values (?1,?2)) as temp(t1,t2))"); - } - - @Override - protected void renderDiff(FunctionRenderContext context) { - renderer.start(context).addArgument(0).addArgument(1).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.year; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class PostgreSQLYearDiffFunction extends YearDiffFunction { + + public PostgreSQLYearDiffFunction() { + super("(select date_part('year', t2) - date_part('year', t1) from (values (?1,?2)) as temp(t1,t2))"); + } + + @Override + protected void renderDiff(FunctionRenderContext context) { + renderer.start(context).addArgument(0).addArgument(1).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/YearDiffFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/YearDiffFunction.java index 156bea6ae3..a57047ee05 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/YearDiffFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datediff/year/YearDiffFunction.java @@ -1,30 +1,30 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datediff.year; - -import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class YearDiffFunction extends DateDiffFunction { - - public YearDiffFunction(String template) { - super("year_diff", template); - } +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datediff.year; + +import com.blazebit.persistence.impl.function.datediff.DateDiffFunction; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class YearDiffFunction extends DateDiffFunction { + + public YearDiffFunction(String template) { + super("year_diff", template); + } } \ No newline at end of file diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/AccessDayFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/AccessDayFunction.java index e65dd4fcc2..da9aa892cc 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/AccessDayFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/AccessDayFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.day; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessDayFunction extends DayFunction { - - public AccessDayFunction() { - super("datepart('d', ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.day; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessDayFunction extends DayFunction { + + public AccessDayFunction() { + super("datepart('d', ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DB2DayFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DB2DayFunction.java index 5597995c3e..3462b9cf82 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DB2DayFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DB2DayFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.day; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DB2DayFunction extends DayFunction { - - public DB2DayFunction() { - super("day(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.day; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DB2DayFunction extends DayFunction { + + public DB2DayFunction() { + super("day(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DayFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DayFunction.java index a7a149db23..32a3145b65 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DayFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DayFunction.java @@ -1,62 +1,62 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.day; - -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.TemplateRenderer; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DayFunction implements JpqlFunction { - - private final TemplateRenderer renderer; - - public DayFunction() { - this.renderer = new TemplateRenderer("extract(day from ?1)"); - } - - public DayFunction(String template) { - this.renderer = new TemplateRenderer(template); - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return Integer.class; - } - - @Override - public void render(FunctionRenderContext context) { - if (context.getArgumentsSize() != 1) { - throw new RuntimeException("The day function needs exactly one argument ! args=" + context); - } - - renderer.start(context).addArgument(0).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.day; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.TemplateRenderer; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DayFunction implements JpqlFunction { + + private final TemplateRenderer renderer; + + public DayFunction() { + this.renderer = new TemplateRenderer("extract(day from ?1)"); + } + + public DayFunction(String template) { + this.renderer = new TemplateRenderer(template); + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return Integer.class; + } + + @Override + public void render(FunctionRenderContext context) { + if (context.getArgumentsSize() != 1) { + throw new RuntimeException("The day function needs exactly one argument ! args=" + context); + } + + renderer.start(context).addArgument(0).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DerbyDayFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DerbyDayFunction.java index b99a532cfe..09d97c6bb6 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DerbyDayFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/DerbyDayFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.day; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DerbyDayFunction extends DayFunction { - - public DerbyDayFunction() { - super("day(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.day; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DerbyDayFunction extends DayFunction { + + public DerbyDayFunction() { + super("day(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SQLServerDayFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SQLServerDayFunction.java index d79838f19b..8e92693c7a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SQLServerDayFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SQLServerDayFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.day; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SQLServerDayFunction extends DayFunction { - - public SQLServerDayFunction() { - super("datepart(dd, convert(date, ?1))"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.day; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SQLServerDayFunction extends DayFunction { + + public SQLServerDayFunction() { + super("datepart(dd, convert(date, ?1))"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SqliteDayFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SqliteDayFunction.java index 2279605c65..0ac9f88c44 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SqliteDayFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SqliteDayFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.day; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SqliteDayFunction extends DayFunction { - - public SqliteDayFunction() { - super("strftime('%d',?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.day; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SqliteDayFunction extends DayFunction { + + public SqliteDayFunction() { + super("strftime('%d',?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SybaseDayFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SybaseDayFunction.java index 4d1600a458..edc7acc147 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SybaseDayFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/day/SybaseDayFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.day; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SybaseDayFunction extends DayFunction { - - public SybaseDayFunction() { - super("datepart(dd, ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.day; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SybaseDayFunction extends DayFunction { + + public SybaseDayFunction() { + super("datepart(dd, ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/AccessHourFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/AccessHourFunction.java index feb947ee2a..8fd5b8ec08 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/AccessHourFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/AccessHourFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.hour; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessHourFunction extends HourFunction { - - public AccessHourFunction() { - super("datepart('h', ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.hour; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessHourFunction extends HourFunction { + + public AccessHourFunction() { + super("datepart('h', ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/DB2HourFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/DB2HourFunction.java index afebbac138..9187afc41b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/DB2HourFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/DB2HourFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.hour; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DB2HourFunction extends HourFunction { - - public DB2HourFunction() { - super("hour(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.hour; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DB2HourFunction extends HourFunction { + + public DB2HourFunction() { + super("hour(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/DerbyHourFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/DerbyHourFunction.java index 63efc9881a..54f85b0b43 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/DerbyHourFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/DerbyHourFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.hour; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DerbyHourFunction extends HourFunction { - - public DerbyHourFunction() { - super("hour(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.hour; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DerbyHourFunction extends HourFunction { + + public DerbyHourFunction() { + super("hour(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/HourFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/HourFunction.java index 65bd93245c..9c4158cc15 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/HourFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/HourFunction.java @@ -1,62 +1,62 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.hour; - -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.TemplateRenderer; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class HourFunction implements JpqlFunction { - - private final TemplateRenderer renderer; - - public HourFunction() { - this.renderer = new TemplateRenderer("extract(hour from ?1)"); - } - - public HourFunction(String template) { - this.renderer = new TemplateRenderer(template); - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return Integer.class; - } - - @Override - public void render(FunctionRenderContext context) { - if (context.getArgumentsSize() != 1) { - throw new RuntimeException("The hour function needs exactly one argument ! args=" + context); - } - - renderer.start(context).addArgument(0).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.hour; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.TemplateRenderer; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class HourFunction implements JpqlFunction { + + private final TemplateRenderer renderer; + + public HourFunction() { + this.renderer = new TemplateRenderer("extract(hour from ?1)"); + } + + public HourFunction(String template) { + this.renderer = new TemplateRenderer(template); + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return Integer.class; + } + + @Override + public void render(FunctionRenderContext context) { + if (context.getArgumentsSize() != 1) { + throw new RuntimeException("The hour function needs exactly one argument ! args=" + context); + } + + renderer.start(context).addArgument(0).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SQLServerHourFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SQLServerHourFunction.java index cb26d22bef..1416756ec0 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SQLServerHourFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SQLServerHourFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.hour; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SQLServerHourFunction extends HourFunction { - - public SQLServerHourFunction() { - super("datepart(hh, convert(date, ?1))"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.hour; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SQLServerHourFunction extends HourFunction { + + public SQLServerHourFunction() { + super("datepart(hh, convert(date, ?1))"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SqliteHourFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SqliteHourFunction.java index b64d8cdf46..31a7ee73ba 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SqliteHourFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SqliteHourFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.hour; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SqliteHourFunction extends HourFunction { - - public SqliteHourFunction() { - super("strftime('%H',?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.hour; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SqliteHourFunction extends HourFunction { + + public SqliteHourFunction() { + super("strftime('%H',?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SybaseHourFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SybaseHourFunction.java index a6bf4f07f6..039fb76cb8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SybaseHourFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/hour/SybaseHourFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.hour; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SybaseHourFunction extends HourFunction { - - public SybaseHourFunction() { - super("datepart(hh, ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.hour; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SybaseHourFunction extends HourFunction { + + public SybaseHourFunction() { + super("datepart(hh, ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/AccessMinuteFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/AccessMinuteFunction.java index f1d29ac433..c3d9ce7e33 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/AccessMinuteFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/AccessMinuteFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.minute; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessMinuteFunction extends MinuteFunction { - - public AccessMinuteFunction() { - super("datepart('n', ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.minute; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessMinuteFunction extends MinuteFunction { + + public AccessMinuteFunction() { + super("datepart('n', ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/DB2MinuteFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/DB2MinuteFunction.java index 5fc33c9147..f3ab9fbf8a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/DB2MinuteFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/DB2MinuteFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.minute; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DB2MinuteFunction extends MinuteFunction { - - public DB2MinuteFunction() { - super("minute(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.minute; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DB2MinuteFunction extends MinuteFunction { + + public DB2MinuteFunction() { + super("minute(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/DerbyMinuteFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/DerbyMinuteFunction.java index 5bccaf9904..e30f0ab169 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/DerbyMinuteFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/DerbyMinuteFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.minute; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DerbyMinuteFunction extends MinuteFunction { - - public DerbyMinuteFunction() { - super("minute(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.minute; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DerbyMinuteFunction extends MinuteFunction { + + public DerbyMinuteFunction() { + super("minute(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/MinuteFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/MinuteFunction.java index 4d3c54fcaf..ddf55b5bf4 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/MinuteFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/MinuteFunction.java @@ -1,62 +1,62 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.minute; - -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.TemplateRenderer; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MinuteFunction implements JpqlFunction { - - private final TemplateRenderer renderer; - - public MinuteFunction() { - this.renderer = new TemplateRenderer("extract(minute from ?1)"); - } - - public MinuteFunction(String template) { - this.renderer = new TemplateRenderer(template); - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return Integer.class; - } - - @Override - public void render(FunctionRenderContext context) { - if (context.getArgumentsSize() != 1) { - throw new RuntimeException("The minute function needs exactly one argument ! args=" + context); - } - - renderer.start(context).addArgument(0).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.minute; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.TemplateRenderer; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MinuteFunction implements JpqlFunction { + + private final TemplateRenderer renderer; + + public MinuteFunction() { + this.renderer = new TemplateRenderer("extract(minute from ?1)"); + } + + public MinuteFunction(String template) { + this.renderer = new TemplateRenderer(template); + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return Integer.class; + } + + @Override + public void render(FunctionRenderContext context) { + if (context.getArgumentsSize() != 1) { + throw new RuntimeException("The minute function needs exactly one argument ! args=" + context); + } + + renderer.start(context).addArgument(0).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SQLServerMinuteFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SQLServerMinuteFunction.java index e049a355f3..601ad352d6 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SQLServerMinuteFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SQLServerMinuteFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.minute; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SQLServerMinuteFunction extends MinuteFunction { - - public SQLServerMinuteFunction() { - super("datepart(mi, convert(date, ?1))"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.minute; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SQLServerMinuteFunction extends MinuteFunction { + + public SQLServerMinuteFunction() { + super("datepart(mi, convert(date, ?1))"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SqliteMinuteFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SqliteMinuteFunction.java index a903d9925c..0a75ebcaf7 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SqliteMinuteFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SqliteMinuteFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.minute; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SqliteMinuteFunction extends MinuteFunction { - - public SqliteMinuteFunction() { - super("strftime('%M',?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.minute; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SqliteMinuteFunction extends MinuteFunction { + + public SqliteMinuteFunction() { + super("strftime('%M',?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SybaseMinuteFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SybaseMinuteFunction.java index 9d50abdc34..a90d4efb51 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SybaseMinuteFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/minute/SybaseMinuteFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.minute; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SybaseMinuteFunction extends MinuteFunction { - - public SybaseMinuteFunction() { - super("datepart(mi, ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.minute; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SybaseMinuteFunction extends MinuteFunction { + + public SybaseMinuteFunction() { + super("datepart(mi, ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/AccessMonthFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/AccessMonthFunction.java index 365bdbad86..aa0802456b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/AccessMonthFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/AccessMonthFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.month; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessMonthFunction extends MonthFunction { - - public AccessMonthFunction() { - super("datepart('m', ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.month; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessMonthFunction extends MonthFunction { + + public AccessMonthFunction() { + super("datepart('m', ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/DB2MonthFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/DB2MonthFunction.java index b0fe46508c..80cc656cf9 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/DB2MonthFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/DB2MonthFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.month; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DB2MonthFunction extends MonthFunction { - - public DB2MonthFunction() { - super("month(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.month; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DB2MonthFunction extends MonthFunction { + + public DB2MonthFunction() { + super("month(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/DerbyMonthFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/DerbyMonthFunction.java index 7ff29a989a..5a0338e745 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/DerbyMonthFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/DerbyMonthFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.month; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DerbyMonthFunction extends MonthFunction { - - public DerbyMonthFunction() { - super("month(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.month; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DerbyMonthFunction extends MonthFunction { + + public DerbyMonthFunction() { + super("month(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/MonthFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/MonthFunction.java index e2e7b7b2e0..73ff517e7e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/MonthFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/MonthFunction.java @@ -1,62 +1,62 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.month; - -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.TemplateRenderer; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MonthFunction implements JpqlFunction { - - private final TemplateRenderer renderer; - - public MonthFunction() { - this.renderer = new TemplateRenderer("extract(month from ?1)"); - } - - public MonthFunction(String template) { - this.renderer = new TemplateRenderer(template); - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return Integer.class; - } - - @Override - public void render(FunctionRenderContext context) { - if (context.getArgumentsSize() != 1) { - throw new RuntimeException("The month function needs exactly one argument ! args=" + context); - } - - renderer.start(context).addArgument(0).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.month; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.TemplateRenderer; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MonthFunction implements JpqlFunction { + + private final TemplateRenderer renderer; + + public MonthFunction() { + this.renderer = new TemplateRenderer("extract(month from ?1)"); + } + + public MonthFunction(String template) { + this.renderer = new TemplateRenderer(template); + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return Integer.class; + } + + @Override + public void render(FunctionRenderContext context) { + if (context.getArgumentsSize() != 1) { + throw new RuntimeException("The month function needs exactly one argument ! args=" + context); + } + + renderer.start(context).addArgument(0).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SQLServerMonthFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SQLServerMonthFunction.java index 053dfc4b5a..804adc25e6 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SQLServerMonthFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SQLServerMonthFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.month; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SQLServerMonthFunction extends MonthFunction { - - public SQLServerMonthFunction() { - super("datepart(mm, convert(date, ?1))"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.month; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SQLServerMonthFunction extends MonthFunction { + + public SQLServerMonthFunction() { + super("datepart(mm, convert(date, ?1))"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SqliteMonthFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SqliteMonthFunction.java index d69f9cd5a5..025298976e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SqliteMonthFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SqliteMonthFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.month; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SqliteMonthFunction extends MonthFunction { - - public SqliteMonthFunction() { - super("strftime('%m',?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.month; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SqliteMonthFunction extends MonthFunction { + + public SqliteMonthFunction() { + super("strftime('%m',?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SybaseMonthFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SybaseMonthFunction.java index f5fbb5e347..3ee2877e87 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SybaseMonthFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/month/SybaseMonthFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.month; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SybaseMonthFunction extends MonthFunction { - - public SybaseMonthFunction() { - super("datepart(mm, ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.month; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SybaseMonthFunction extends MonthFunction { + + public SybaseMonthFunction() { + super("datepart(mm, ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/AccessSecondFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/AccessSecondFunction.java index b1596bb3de..2fffcc3ae0 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/AccessSecondFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/AccessSecondFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.second; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessSecondFunction extends SecondFunction { - - public AccessSecondFunction() { - super("datepart('s', ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.second; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessSecondFunction extends SecondFunction { + + public AccessSecondFunction() { + super("datepart('s', ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/DB2SecondFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/DB2SecondFunction.java index f2f58a9ae8..4b53dba305 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/DB2SecondFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/DB2SecondFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.second; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DB2SecondFunction extends SecondFunction { - - public DB2SecondFunction() { - super("second(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.second; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DB2SecondFunction extends SecondFunction { + + public DB2SecondFunction() { + super("second(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/DerbySecondFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/DerbySecondFunction.java index 3b87539c69..4feebed945 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/DerbySecondFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/DerbySecondFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.second; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DerbySecondFunction extends SecondFunction { - - public DerbySecondFunction() { - super("second(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.second; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DerbySecondFunction extends SecondFunction { + + public DerbySecondFunction() { + super("second(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SQLServerSecondFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SQLServerSecondFunction.java index 76f73f133f..3680d73c1c 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SQLServerSecondFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SQLServerSecondFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.second; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SQLServerSecondFunction extends SecondFunction { - - public SQLServerSecondFunction() { - super("datepart(ss, convert(date, ?1))"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.second; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SQLServerSecondFunction extends SecondFunction { + + public SQLServerSecondFunction() { + super("datepart(ss, convert(date, ?1))"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SecondFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SecondFunction.java index 2449744b5c..43432d81f6 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SecondFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SecondFunction.java @@ -1,62 +1,62 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.second; - -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.TemplateRenderer; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SecondFunction implements JpqlFunction { - - private final TemplateRenderer renderer; - - public SecondFunction() { - this.renderer = new TemplateRenderer("extract(second from ?1)"); - } - - public SecondFunction(String template) { - this.renderer = new TemplateRenderer(template); - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return Integer.class; - } - - @Override - public void render(FunctionRenderContext context) { - if (context.getArgumentsSize() != 1) { - throw new RuntimeException("The second function needs exactly one argument ! args=" + context); - } - - renderer.start(context).addArgument(0).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.second; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.TemplateRenderer; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SecondFunction implements JpqlFunction { + + private final TemplateRenderer renderer; + + public SecondFunction() { + this.renderer = new TemplateRenderer("extract(second from ?1)"); + } + + public SecondFunction(String template) { + this.renderer = new TemplateRenderer(template); + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return Integer.class; + } + + @Override + public void render(FunctionRenderContext context) { + if (context.getArgumentsSize() != 1) { + throw new RuntimeException("The second function needs exactly one argument ! args=" + context); + } + + renderer.start(context).addArgument(0).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SqliteSecondFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SqliteSecondFunction.java index a1933533e5..bd163a59d9 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SqliteSecondFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SqliteSecondFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.second; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SqliteSecondFunction extends SecondFunction { - - public SqliteSecondFunction() { - super("strftime('%S',?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.second; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SqliteSecondFunction extends SecondFunction { + + public SqliteSecondFunction() { + super("strftime('%S',?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SybaseSecondFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SybaseSecondFunction.java index 2ebee7c520..1f3f4e129d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SybaseSecondFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/second/SybaseSecondFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.second; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SybaseSecondFunction extends SecondFunction { - - public SybaseSecondFunction() { - super("datepart(ss, ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.second; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SybaseSecondFunction extends SecondFunction { + + public SybaseSecondFunction() { + super("datepart(ss, ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/AccessYearFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/AccessYearFunction.java index db2e80147e..8f0400d64a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/AccessYearFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/AccessYearFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.year; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AccessYearFunction extends YearFunction { - - public AccessYearFunction() { - super("datepart('yyyy', ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.year; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AccessYearFunction extends YearFunction { + + public AccessYearFunction() { + super("datepart('yyyy', ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/DB2YearFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/DB2YearFunction.java index 7e7437647a..ed300f1684 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/DB2YearFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/DB2YearFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.year; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DB2YearFunction extends YearFunction { - - public DB2YearFunction() { - super("year(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.year; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DB2YearFunction extends YearFunction { + + public DB2YearFunction() { + super("year(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/DerbyYearFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/DerbyYearFunction.java index 2078dbf1ef..42f4410a8a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/DerbyYearFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/DerbyYearFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.year; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class DerbyYearFunction extends YearFunction { - - public DerbyYearFunction() { - super("year(?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.year; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class DerbyYearFunction extends YearFunction { + + public DerbyYearFunction() { + super("year(?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SQLServerYearFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SQLServerYearFunction.java index db9027d204..dfc732551a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SQLServerYearFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SQLServerYearFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.year; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SQLServerYearFunction extends YearFunction { - - public SQLServerYearFunction() { - super("datepart(yy, convert(date, ?1))"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.year; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SQLServerYearFunction extends YearFunction { + + public SQLServerYearFunction() { + super("datepart(yy, convert(date, ?1))"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SqliteYearFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SqliteYearFunction.java index afd992a71b..9862f1a8b1 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SqliteYearFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SqliteYearFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.year; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SqliteYearFunction extends YearFunction { - - public SqliteYearFunction() { - super("strftime('%Y',?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.year; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SqliteYearFunction extends YearFunction { + + public SqliteYearFunction() { + super("strftime('%Y',?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SybaseYearFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SybaseYearFunction.java index 0c7b2325df..3ad4e2cd90 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SybaseYearFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/SybaseYearFunction.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.year; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SybaseYearFunction extends YearFunction { - - public SybaseYearFunction() { - super("datepart(yy, ?1)"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.year; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SybaseYearFunction extends YearFunction { + + public SybaseYearFunction() { + super("datepart(yy, ?1)"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/YearFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/YearFunction.java index 94cf98cbf2..c4ed52f3ff 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/YearFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/datetime/year/YearFunction.java @@ -1,62 +1,62 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.datetime.year; - -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.TemplateRenderer; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class YearFunction implements JpqlFunction { - - private final TemplateRenderer renderer; - - public YearFunction() { - this.renderer = new TemplateRenderer("extract(year from ?1)"); - } - - public YearFunction(String template) { - this.renderer = new TemplateRenderer(template); - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return Integer.class; - } - - @Override - public void render(FunctionRenderContext context) { - if (context.getArgumentsSize() != 1) { - throw new RuntimeException("The year function needs exactly one argument ! args=" + context); - } - - renderer.start(context).addArgument(0).build(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.datetime.year; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.TemplateRenderer; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class YearFunction implements JpqlFunction { + + private final TemplateRenderer renderer; + + public YearFunction() { + this.renderer = new TemplateRenderer("extract(year from ?1)"); + } + + public YearFunction(String template) { + this.renderer = new TemplateRenderer(template); + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return Integer.class; + } + + @Override + public void render(FunctionRenderContext context) { + if (context.getArgumentsSize() != 1) { + throw new RuntimeException("The year function needs exactly one argument ! args=" + context); + } + + renderer.start(context).addArgument(0).build(); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/limit/LimitFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/limit/LimitFunction.java index 5204f7c500..0b947fc616 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/limit/LimitFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/limit/LimitFunction.java @@ -1,92 +1,92 @@ -package com.blazebit.persistence.impl.function.limit; - -import com.blazebit.persistence.spi.DbmsDialect; -import com.blazebit.persistence.spi.DbmsStatementType; -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; - -/** - * - * @author Christian Beikov - * @since 1.0.1 - */ -public class LimitFunction implements JpqlFunction { - - protected final DbmsDialect dbmsDialect; - - public LimitFunction(DbmsDialect dbmsDialect) { - // LIMIT(SUBQUERY, LIMIT, OFFSET) - this.dbmsDialect = dbmsDialect; - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return firstArgumentType; - } - - @Override - public void render(FunctionRenderContext functionRenderContext) { - switch (functionRenderContext.getArgumentsSize()) { - case 3: - if (isNotNull(functionRenderContext.getArgument(1)) && isNotNull(functionRenderContext.getArgument(2))) { - renderLimitOffset(functionRenderContext); - return; - } - - break; - case 2: - if (isNotNull(functionRenderContext.getArgument(1))) { - renderLimitOnly(functionRenderContext); - return; - } - - break; - default: - break; - } - - throw new RuntimeException("The limit function needs two or three non null arguments , and optionally ! args=" - + functionRenderContext); - } - - protected void renderLimitOffset(FunctionRenderContext functionRenderContext) { - StringBuilder sqlSb = getSql(functionRenderContext); - dbmsDialect.appendExtendedSql(sqlSb, DbmsStatementType.SELECT, true, false, null, functionRenderContext.getArgument(1), functionRenderContext.getArgument(2), null, null); - functionRenderContext.addChunk(sqlSb.toString()); - } - - protected void renderLimitOnly(FunctionRenderContext functionRenderContext) { - StringBuilder sqlSb = getSql(functionRenderContext); - dbmsDialect.appendExtendedSql(sqlSb, DbmsStatementType.SELECT, true, false, null, functionRenderContext.getArgument(1), null, null, null); - functionRenderContext.addChunk(sqlSb.toString()); - } - - private static boolean isNotNull(String argument) { - return argument != null && !"NULL".equalsIgnoreCase(argument); - } - - private static StringBuilder getSql(FunctionRenderContext functionRenderContext) { - String subquery = functionRenderContext.getArgument(0); - if (startsWithIgnoreCase(subquery, "(select")) { - int endIndex = subquery.length() - (subquery.charAt(subquery.length() - 1) == ')' ? 1 : 0); - return new StringBuilder(subquery.length() - 2).append(subquery, 1, endIndex); - } - - return new StringBuilder(subquery); - } - - private static boolean startsWithIgnoreCase(String s1, String s2) { - return s1.regionMatches(true, 0, s2, 0, s2.length()); - } - -} +package com.blazebit.persistence.impl.function.limit; + +import com.blazebit.persistence.spi.DbmsDialect; +import com.blazebit.persistence.spi.DbmsStatementType; +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; + +/** + * + * @author Christian Beikov + * @since 1.0.1 + */ +public class LimitFunction implements JpqlFunction { + + protected final DbmsDialect dbmsDialect; + + public LimitFunction(DbmsDialect dbmsDialect) { + // LIMIT(SUBQUERY, LIMIT, OFFSET) + this.dbmsDialect = dbmsDialect; + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return firstArgumentType; + } + + @Override + public void render(FunctionRenderContext functionRenderContext) { + switch (functionRenderContext.getArgumentsSize()) { + case 3: + if (isNotNull(functionRenderContext.getArgument(1)) && isNotNull(functionRenderContext.getArgument(2))) { + renderLimitOffset(functionRenderContext); + return; + } + + break; + case 2: + if (isNotNull(functionRenderContext.getArgument(1))) { + renderLimitOnly(functionRenderContext); + return; + } + + break; + default: + break; + } + + throw new RuntimeException("The limit function needs two or three non null arguments , and optionally ! args=" + + functionRenderContext); + } + + protected void renderLimitOffset(FunctionRenderContext functionRenderContext) { + StringBuilder sqlSb = getSql(functionRenderContext); + dbmsDialect.appendExtendedSql(sqlSb, DbmsStatementType.SELECT, true, false, null, functionRenderContext.getArgument(1), functionRenderContext.getArgument(2), null, null); + functionRenderContext.addChunk(sqlSb.toString()); + } + + protected void renderLimitOnly(FunctionRenderContext functionRenderContext) { + StringBuilder sqlSb = getSql(functionRenderContext); + dbmsDialect.appendExtendedSql(sqlSb, DbmsStatementType.SELECT, true, false, null, functionRenderContext.getArgument(1), null, null, null); + functionRenderContext.addChunk(sqlSb.toString()); + } + + private static boolean isNotNull(String argument) { + return argument != null && !"NULL".equalsIgnoreCase(argument); + } + + private static StringBuilder getSql(FunctionRenderContext functionRenderContext) { + String subquery = functionRenderContext.getArgument(0); + if (startsWithIgnoreCase(subquery, "(select")) { + int endIndex = subquery.length() - (subquery.charAt(subquery.length() - 1) == ')' ? 1 : 0); + return new StringBuilder(subquery.length() - 2).append(subquery, 1, endIndex); + } + + return new StringBuilder(subquery); + } + + private static boolean startsWithIgnoreCase(String s1, String s2) { + return s1.regionMatches(true, 0, s2, 0, s2.length()); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/MySQLPagePositionFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/MySQLPagePositionFunction.java index d4e051bb63..b823e97b19 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/MySQLPagePositionFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/MySQLPagePositionFunction.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.pageposition; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class MySQLPagePositionFunction extends PagePositionFunction { - - public MySQLPagePositionFunction() { - super("(select rownumber_ from (select @i:=@i+1 as rownumber_, base_.* from (?1) as base_, (SELECT @i:=0) as iter_) as base1_ where ?2 = base1_.?3)"); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.pageposition; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class MySQLPagePositionFunction extends PagePositionFunction { + + public MySQLPagePositionFunction() { + super("(select rownumber_ from (select @i:=@i+1 as rownumber_, base_.* from (?1) as base_, (SELECT @i:=0) as iter_) as base1_ where ?2 = base1_.?3)"); + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/OraclePagePositionFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/OraclePagePositionFunction.java index 824ac863e8..d73930ae05 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/OraclePagePositionFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/OraclePagePositionFunction.java @@ -1,30 +1,30 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.pageposition; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class OraclePagePositionFunction extends PagePositionFunction { - - @Override - protected String getRownumFunction() { - return "rownum"; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.pageposition; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class OraclePagePositionFunction extends PagePositionFunction { + + @Override + protected String getRownumFunction() { + return "rownum"; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/PagePositionFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/PagePositionFunction.java index 9eeac4dc47..df336b627d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/PagePositionFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/PagePositionFunction.java @@ -1,98 +1,98 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.pageposition; - -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.TemplateRenderer; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class PagePositionFunction implements JpqlFunction { - - protected final TemplateRenderer renderer; - - public PagePositionFunction() { - this.renderer = new TemplateRenderer("(select base1_.rownumber_ from (select " + getRownumFunction() - + " as rownumber_, base_.* from ?1 as base_) as base1_ where ?2 = base1_.?3)"); - } - - public PagePositionFunction(String template) { - this.renderer = new TemplateRenderer(template); - } - - protected String getRownumFunction() { - return "row_number() over ()"; - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return Long.class; - } - - @Override - public void render(FunctionRenderContext context) { - if (context.getArgumentsSize() != 2) { - throw new RuntimeException("The page position function needs exactly two arguments and ! args=" + context); - } - - String subquery = context.getArgument(0); - String subqueryStart = "(select "; - int fromIndex; - - if (!startsWithIgnoreCase(subquery, subqueryStart)) { - throw new IllegalArgumentException("Expected a subquery as the second parameter but was: " + subquery); - } else if ((fromIndex = subquery.toLowerCase().indexOf(" from ")) < 1) { - throw new IllegalArgumentException("Expected a subquery as the second parameter but was: " + subquery); - } - - String id = subquery.substring(subqueryStart.length(), fromIndex); - - if (id.indexOf(',') > -1) { - throw new IllegalArgumentException("Expected a subquery with a simple id but it was composite: " + subquery); - } - - int dotIndex = id.indexOf('.'); - - if (dotIndex < 0) { - throw new IllegalArgumentException("Expected that the id is fully qualified but it isn't: " + id); - } - - String idName = id.substring(dotIndex + 1); - renderPagePosition(context, idName); - } - - protected void renderPagePosition(FunctionRenderContext functionRenderContext, String idName) { - renderer.start(functionRenderContext).addArgument(0).addArgument(1).addParameter(idName).build(); - } - - private boolean startsWithIgnoreCase(String s1, String s2) { - return s1.regionMatches(true, 0, s2, 0, s2.length()); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.pageposition; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.TemplateRenderer; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class PagePositionFunction implements JpqlFunction { + + protected final TemplateRenderer renderer; + + public PagePositionFunction() { + this.renderer = new TemplateRenderer("(select base1_.rownumber_ from (select " + getRownumFunction() + + " as rownumber_, base_.* from ?1 as base_) as base1_ where ?2 = base1_.?3)"); + } + + public PagePositionFunction(String template) { + this.renderer = new TemplateRenderer(template); + } + + protected String getRownumFunction() { + return "row_number() over ()"; + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return Long.class; + } + + @Override + public void render(FunctionRenderContext context) { + if (context.getArgumentsSize() != 2) { + throw new RuntimeException("The page position function needs exactly two arguments and ! args=" + context); + } + + String subquery = context.getArgument(0); + String subqueryStart = "(select "; + int fromIndex; + + if (!startsWithIgnoreCase(subquery, subqueryStart)) { + throw new IllegalArgumentException("Expected a subquery as the second parameter but was: " + subquery); + } else if ((fromIndex = subquery.toLowerCase().indexOf(" from ")) < 1) { + throw new IllegalArgumentException("Expected a subquery as the second parameter but was: " + subquery); + } + + String id = subquery.substring(subqueryStart.length(), fromIndex); + + if (id.indexOf(',') > -1) { + throw new IllegalArgumentException("Expected a subquery with a simple id but it was composite: " + subquery); + } + + int dotIndex = id.indexOf('.'); + + if (dotIndex < 0) { + throw new IllegalArgumentException("Expected that the id is fully qualified but it isn't: " + id); + } + + String idName = id.substring(dotIndex + 1); + renderPagePosition(context, idName); + } + + protected void renderPagePosition(FunctionRenderContext functionRenderContext, String idName) { + renderer.start(functionRenderContext).addArgument(0).addArgument(1).addParameter(idName).build(); + } + + private boolean startsWithIgnoreCase(String s1, String s2) { + return s1.regionMatches(true, 0, s2, 0, s2.length()); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/TransactSQLPagePositionFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/TransactSQLPagePositionFunction.java index 97b6fb2d3d..bc274ff0a8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/TransactSQLPagePositionFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/pageposition/TransactSQLPagePositionFunction.java @@ -1,30 +1,30 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.function.pageposition; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class TransactSQLPagePositionFunction extends PagePositionFunction { - - @Override - protected String getRownumFunction() { - return "row_number() over(order by (select 0))"; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.function.pageposition; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class TransactSQLPagePositionFunction extends PagePositionFunction { + + @Override + protected String getRownumFunction() { + return "row_number() over(order by (select 0))"; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/set/SetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/set/SetFunction.java index 64b93406ed..cdc4616fc4 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/set/SetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/set/SetFunction.java @@ -1,102 +1,102 @@ -package com.blazebit.persistence.impl.function.set; - -import java.util.ArrayList; -import java.util.List; - -import com.blazebit.persistence.impl.DefaultOrderByElement; -import com.blazebit.persistence.spi.DbmsDialect; -import com.blazebit.persistence.spi.FunctionRenderContext; -import com.blazebit.persistence.spi.JpqlFunction; -import com.blazebit.persistence.spi.OrderByElement; -import com.blazebit.persistence.spi.SetOperationType; - -/** - * - * @author Christian Beikov - * @since 1.1.0 - */ -public class SetFunction implements JpqlFunction { - - protected final SetOperationType type; - protected final DbmsDialect dbmsDialect; - - public SetFunction(SetOperationType type, DbmsDialect dbmsDialect) { - // OPERATION(SUBQUERY, ...) - this.type = type; - this.dbmsDialect = dbmsDialect; - } - - @Override - public boolean hasArguments() { - return true; - } - - @Override - public boolean hasParenthesesIfNoArguments() { - return true; - } - - @Override - public Class getReturnType(Class firstArgumentType) { - return firstArgumentType; - } - - @Override - public void render(FunctionRenderContext functionRenderContext) { - if (functionRenderContext.getArgumentsSize() == 0) { - throw new RuntimeException("The " + type + " function needs at least one argument ! args=" + functionRenderContext); - } - - int size = 0; - Mode mode = Mode.SUBQUERIES; - List operands = new ArrayList(functionRenderContext.getArgumentsSize()); - List orderByElements = new ArrayList(0); - String limit = null; - String offset = null; - for (int i = 0; i < functionRenderContext.getArgumentsSize(); i++) { - String argument = functionRenderContext.getArgument(i); - - if ("'ORDER_BY'".equals(argument)) { - mode = Mode.ORDER_BYS; - size += argument.length(); - } else if ("'LIMIT'".equals(argument)) { - mode = Mode.LIMIT; - size += argument.length(); - } else if ("'OFFSET'".equals(argument)) { - mode = Mode.OFFSET; - size += argument.length(); - } else { - switch (mode) { - case SUBQUERIES: - size += argument.length(); - operands.add(argument); - break; - case ORDER_BYS: - size += argument.length() + 30; - orderByElements.add(DefaultOrderByElement.fromString(argument, 1, argument.length() - 2)); - break; - case LIMIT: - size += argument.length() + 30; - limit = argument; - break; - case OFFSET: - size += argument.length() + 30; - offset = argument; - break; - } - } - } - - StringBuilder sqlSb = new StringBuilder(size + functionRenderContext.getArgumentsSize() * 12); - dbmsDialect.appendSet(sqlSb, type, true, operands, orderByElements, limit, offset); - functionRenderContext.addChunk(sqlSb.toString()); - } - - private static enum Mode { - SUBQUERIES, - ORDER_BYS, - LIMIT, - OFFSET; - } - -} +package com.blazebit.persistence.impl.function.set; + +import java.util.ArrayList; +import java.util.List; + +import com.blazebit.persistence.impl.DefaultOrderByElement; +import com.blazebit.persistence.spi.DbmsDialect; +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.OrderByElement; +import com.blazebit.persistence.spi.SetOperationType; + +/** + * + * @author Christian Beikov + * @since 1.1.0 + */ +public class SetFunction implements JpqlFunction { + + protected final SetOperationType type; + protected final DbmsDialect dbmsDialect; + + public SetFunction(SetOperationType type, DbmsDialect dbmsDialect) { + // OPERATION(SUBQUERY, ...) + this.type = type; + this.dbmsDialect = dbmsDialect; + } + + @Override + public boolean hasArguments() { + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + return firstArgumentType; + } + + @Override + public void render(FunctionRenderContext functionRenderContext) { + if (functionRenderContext.getArgumentsSize() == 0) { + throw new RuntimeException("The " + type + " function needs at least one argument ! args=" + functionRenderContext); + } + + int size = 0; + Mode mode = Mode.SUBQUERIES; + List operands = new ArrayList(functionRenderContext.getArgumentsSize()); + List orderByElements = new ArrayList(0); + String limit = null; + String offset = null; + for (int i = 0; i < functionRenderContext.getArgumentsSize(); i++) { + String argument = functionRenderContext.getArgument(i); + + if ("'ORDER_BY'".equals(argument)) { + mode = Mode.ORDER_BYS; + size += argument.length(); + } else if ("'LIMIT'".equals(argument)) { + mode = Mode.LIMIT; + size += argument.length(); + } else if ("'OFFSET'".equals(argument)) { + mode = Mode.OFFSET; + size += argument.length(); + } else { + switch (mode) { + case SUBQUERIES: + size += argument.length(); + operands.add(argument); + break; + case ORDER_BYS: + size += argument.length() + 30; + orderByElements.add(DefaultOrderByElement.fromString(argument, 1, argument.length() - 2)); + break; + case LIMIT: + size += argument.length() + 30; + limit = argument; + break; + case OFFSET: + size += argument.length() + 30; + offset = argument; + break; + } + } + } + + StringBuilder sqlSb = new StringBuilder(size + functionRenderContext.getArgumentsSize() * 12); + dbmsDialect.appendSet(sqlSb, type, true, operands, orderByElements, limit, offset); + functionRenderContext.addChunk(sqlSb.toString()); + } + + private static enum Mode { + SUBQUERIES, + ORDER_BYS, + LIMIT, + OFFSET; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/jpaprovider/HibernateJpa21Provider.java b/core/impl/src/main/java/com/blazebit/persistence/impl/jpaprovider/HibernateJpa21Provider.java index 6bd74d2e31..2e29900640 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/jpaprovider/HibernateJpa21Provider.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/jpaprovider/HibernateJpa21Provider.java @@ -1,41 +1,41 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.jpaprovider; - -import javax.persistence.EntityManager; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class HibernateJpa21Provider extends HibernateJpaProvider { - - public HibernateJpa21Provider(EntityManager em, String dbms) { - super(em, dbms); - } - - @Override - public boolean supportsJpa21() { - return true; - } - - @Override - public String getOnClause() { - return "ON"; - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.jpaprovider; + +import javax.persistence.EntityManager; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class HibernateJpa21Provider extends HibernateJpaProvider { + + public HibernateJpa21Provider(EntityManager em, String dbms) { + super(em, dbms); + } + + @Override + public boolean supportsJpa21() { + return true; + } + + @Override + public String getOnClause() { + return "ON"; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/jpaprovider/JpaProviders.java b/core/impl/src/main/java/com/blazebit/persistence/impl/jpaprovider/JpaProviders.java index 91a97fb709..d724197a16 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/jpaprovider/JpaProviders.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/jpaprovider/JpaProviders.java @@ -1,78 +1,78 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.jpaprovider; - -import javax.persistence.EntityManager; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class JpaProviders { - - public static JpaProvider resolveJpaProvider(EntityManager em, String dbms) { - boolean jpa21 = false; - - try { - EntityManager.class.getMethod("createEntityGraph", Class.class); - jpa21 = true; - } catch (NoSuchMethodException e) { - } - - try { - Class sessionClass = Class.forName("org.hibernate.Session"); - if (em == null || em.unwrap(sessionClass) != null) { - if (jpa21) { - return new HibernateJpa21Provider(em, dbms); - } else { - return new HibernateJpaProvider(em, dbms); - } - } - } catch (ClassNotFoundException e) { - } - - try { - Class jpaEMClass = Class.forName("org.eclipse.persistence.jpa.JpaEntityManager"); - if (em == null || em.unwrap(jpaEMClass) != null) { - Class versionClass = Class.forName("org.eclipse.persistence.Version"); - String version = (String) versionClass.getMethod("getVersion").invoke(null); - String[] versionParts = version.split("\\."); - int major = Integer.parseInt(versionParts[0]); - int minor = Integer.parseInt(versionParts[1]); - - boolean eclipseLink24 = major > 2 || (major == 2 && minor >= 4); - - if (!eclipseLink24) { - throw new IllegalArgumentException("Unsupported EclipseLink version " + version + "!"); - } - - return new EclipseLinkJpaProvider(em); - } - } catch (Exception e) { - } - - try { - Class jpaEMClass = Class.forName("org.datanucleus.ExecutionContext"); - if (em == null || em.unwrap(jpaEMClass) != null) { - return new DataNucleusJpaProvider(em); - } - } catch (Exception e) { - } - - throw new IllegalArgumentException("Unsupported jpa provider!"); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.jpaprovider; + +import javax.persistence.EntityManager; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class JpaProviders { + + public static JpaProvider resolveJpaProvider(EntityManager em, String dbms) { + boolean jpa21 = false; + + try { + EntityManager.class.getMethod("createEntityGraph", Class.class); + jpa21 = true; + } catch (NoSuchMethodException e) { + } + + try { + Class sessionClass = Class.forName("org.hibernate.Session"); + if (em == null || em.unwrap(sessionClass) != null) { + if (jpa21) { + return new HibernateJpa21Provider(em, dbms); + } else { + return new HibernateJpaProvider(em, dbms); + } + } + } catch (ClassNotFoundException e) { + } + + try { + Class jpaEMClass = Class.forName("org.eclipse.persistence.jpa.JpaEntityManager"); + if (em == null || em.unwrap(jpaEMClass) != null) { + Class versionClass = Class.forName("org.eclipse.persistence.Version"); + String version = (String) versionClass.getMethod("getVersion").invoke(null); + String[] versionParts = version.split("\\."); + int major = Integer.parseInt(versionParts[0]); + int minor = Integer.parseInt(versionParts[1]); + + boolean eclipseLink24 = major > 2 || (major == 2 && minor >= 4); + + if (!eclipseLink24) { + throw new IllegalArgumentException("Unsupported EclipseLink version " + version + "!"); + } + + return new EclipseLinkJpaProvider(em); + } + } catch (Exception e) { + } + + try { + Class jpaEMClass = Class.forName("org.datanucleus.ExecutionContext"); + if (em == null || em.unwrap(jpaEMClass) != null) { + return new DataNucleusJpaProvider(em); + } + } catch (Exception e) { + } + + throw new IllegalArgumentException("Unsupported jpa provider!"); + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/AbstractKeysetBuilderEndedListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/AbstractKeysetBuilderEndedListener.java index ce34ef70b6..ed7b3c9e7c 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/AbstractKeysetBuilderEndedListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/AbstractKeysetBuilderEndedListener.java @@ -1,71 +1,71 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.keyset; - -import java.util.Map; - -import com.blazebit.persistence.impl.BuilderChainingException; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class AbstractKeysetBuilderEndedListener implements KeysetBuilderEndedListener { - - private KeysetBuilderImpl currentBuilder; - private KeysetLink keysetLink; - - public void verifyBuilderEnded() { - if (currentBuilder != null) { - throw new BuilderChainingException("A builder was not ended properly."); - } - } - - public KeysetBuilderImpl startBuilder(KeysetBuilderImpl builder) { - if (currentBuilder != null) { - throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); - } - - currentBuilder = builder; - return builder; - } - - @Override - public void onBuilderEnded(KeysetBuilderImpl builder) { - if (currentBuilder == null) { - throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); - } - keysetLink = createLink(builder); - currentBuilder = null; - } - - private KeysetLink createLink(KeysetBuilderImpl builder) { - Map keysetValues = builder.getKeysetValues(); - KeysetMode mode = builder.getMode(); - - return new LazyKeysetLink(keysetValues, mode); - } - - public KeysetLink getKeysetLink() { - return keysetLink; - } - - public void setKeysetLink(KeysetLink keysetLink) { - this.keysetLink = keysetLink; - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.keyset; + +import java.util.Map; + +import com.blazebit.persistence.impl.BuilderChainingException; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class AbstractKeysetBuilderEndedListener implements KeysetBuilderEndedListener { + + private KeysetBuilderImpl currentBuilder; + private KeysetLink keysetLink; + + public void verifyBuilderEnded() { + if (currentBuilder != null) { + throw new BuilderChainingException("A builder was not ended properly."); + } + } + + public KeysetBuilderImpl startBuilder(KeysetBuilderImpl builder) { + if (currentBuilder != null) { + throw new BuilderChainingException("There was an attempt to start a builder but a previous builder was not ended."); + } + + currentBuilder = builder; + return builder; + } + + @Override + public void onBuilderEnded(KeysetBuilderImpl builder) { + if (currentBuilder == null) { + throw new BuilderChainingException("There was an attempt to end a builder that was not started or already closed."); + } + keysetLink = createLink(builder); + currentBuilder = null; + } + + private KeysetLink createLink(KeysetBuilderImpl builder) { + Map keysetValues = builder.getKeysetValues(); + KeysetMode mode = builder.getMode(); + + return new LazyKeysetLink(keysetValues, mode); + } + + public KeysetLink getKeysetLink() { + return keysetLink; + } + + public void setKeysetLink(KeysetLink keysetLink) { + this.keysetLink = keysetLink; + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/AbstractKeysetLink.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/AbstractKeysetLink.java index 547f3dc728..369a3dce0d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/AbstractKeysetLink.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/AbstractKeysetLink.java @@ -1,63 +1,63 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.keyset; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; - -import com.blazebit.persistence.Keyset; -import com.blazebit.persistence.impl.OrderByExpression; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class AbstractKeysetLink implements KeysetLink { - - private final KeysetMode keysetMode; - - public AbstractKeysetLink(KeysetMode keysetMode) { - this.keysetMode = keysetMode; - } - - protected void validate(Keyset keyset, List orderByExpressions) { - if (keyset == null) { - throw new IllegalArgumentException("Invalid null keyset given!"); - } - - Serializable[] key = keyset.getTuple(); - - if (key == null || key.length == 0) { - throw new IllegalArgumentException("Invalid empty keyset key given!"); - } - - if (key.length != orderByExpressions.size()) { - throw new IllegalArgumentException("The given keyset key [" + Arrays.deepToString(key) + "] does not fit the order by expressions " - + orderByExpressions + "!"); - } - - // Unfortunately we can't check types here so we will have to trust the JPA provider to do that - // Still it would be nice to give the user a more informative message if types were wrong - } - - @Override - public KeysetMode getKeysetMode() { - return keysetMode; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.keyset; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +import com.blazebit.persistence.Keyset; +import com.blazebit.persistence.impl.OrderByExpression; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class AbstractKeysetLink implements KeysetLink { + + private final KeysetMode keysetMode; + + public AbstractKeysetLink(KeysetMode keysetMode) { + this.keysetMode = keysetMode; + } + + protected void validate(Keyset keyset, List orderByExpressions) { + if (keyset == null) { + throw new IllegalArgumentException("Invalid null keyset given!"); + } + + Serializable[] key = keyset.getTuple(); + + if (key == null || key.length == 0) { + throw new IllegalArgumentException("Invalid empty keyset key given!"); + } + + if (key.length != orderByExpressions.size()) { + throw new IllegalArgumentException("The given keyset key [" + Arrays.deepToString(key) + "] does not fit the order by expressions " + + orderByExpressions + "!"); + } + + // Unfortunately we can't check types here so we will have to trust the JPA provider to do that + // Still it would be nice to give the user a more informative message if types were wrong + } + + @Override + public KeysetMode getKeysetMode() { + return keysetMode; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetBuilderEndedListener.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetBuilderEndedListener.java index f55012f5ae..31c4f969e0 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetBuilderEndedListener.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetBuilderEndedListener.java @@ -1,26 +1,26 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.keyset; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public interface KeysetBuilderEndedListener { - - public void onBuilderEnded(KeysetBuilderImpl builder); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.keyset; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public interface KeysetBuilderEndedListener { + + public void onBuilderEnded(KeysetBuilderImpl builder); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetBuilderImpl.java index 41ef80daa0..4019bc847a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetBuilderImpl.java @@ -1,62 +1,62 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.keyset; - -import java.util.HashMap; -import java.util.Map; - -import com.blazebit.persistence.KeysetBuilder; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class KeysetBuilderImpl implements KeysetBuilder { - - private final Map keysetValues; - private final T result; - private final KeysetBuilderEndedListener listener; - private final KeysetMode mode; - - public KeysetBuilderImpl(T result, KeysetBuilderEndedListener listener, KeysetMode mode) { - this.keysetValues = new HashMap(); - this.result = result; - this.listener = listener; - this.mode = mode; - } - - @Override - public KeysetBuilder with(String expression, Object value) { - keysetValues.put(expression, value); - return this; - } - - @Override - public T end() { - listener.onBuilderEnded(this); - return result; - } - - public Map getKeysetValues() { - return keysetValues; - } - - public KeysetMode getMode() { - return mode; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.keyset; + +import java.util.HashMap; +import java.util.Map; + +import com.blazebit.persistence.KeysetBuilder; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class KeysetBuilderImpl implements KeysetBuilder { + + private final Map keysetValues; + private final T result; + private final KeysetBuilderEndedListener listener; + private final KeysetMode mode; + + public KeysetBuilderImpl(T result, KeysetBuilderEndedListener listener, KeysetMode mode) { + this.keysetValues = new HashMap(); + this.result = result; + this.listener = listener; + this.mode = mode; + } + + @Override + public KeysetBuilder with(String expression, Object value) { + keysetValues.put(expression, value); + return this; + } + + @Override + public T end() { + listener.onBuilderEnded(this); + return result; + } + + public Map getKeysetValues() { + return keysetValues; + } + + public KeysetMode getMode() { + return mode; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetImpl.java index 6808b20c2d..ba8d5dad1e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetImpl.java @@ -1,65 +1,65 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.keyset; - -import java.io.Serializable; -import java.util.Arrays; - -import com.blazebit.persistence.Keyset; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class KeysetImpl implements Keyset { - - private static final long serialVersionUID = 1L; - - private final Serializable[] tuple; - - public KeysetImpl(Serializable[] tuple) { - this.tuple = tuple; - } - - @Override - public Serializable[] getTuple() { - return tuple; - } - - @Override - public int hashCode() { - int hash = 5; - hash = 53 * hash + Arrays.deepHashCode(this.tuple); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final KeysetImpl other = (KeysetImpl) obj; - if (!Arrays.deepEquals(this.tuple, other.tuple)) { - return false; - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.keyset; + +import java.io.Serializable; +import java.util.Arrays; + +import com.blazebit.persistence.Keyset; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class KeysetImpl implements Keyset { + + private static final long serialVersionUID = 1L; + + private final Serializable[] tuple; + + public KeysetImpl(Serializable[] tuple) { + this.tuple = tuple; + } + + @Override + public Serializable[] getTuple() { + return tuple; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 53 * hash + Arrays.deepHashCode(this.tuple); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final KeysetImpl other = (KeysetImpl) obj; + if (!Arrays.deepEquals(this.tuple, other.tuple)) { + return false; + } + return true; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetLink.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetLink.java index cbd4162f30..d44f6fce41 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetLink.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetLink.java @@ -1,36 +1,36 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.keyset; - -import java.util.List; - -import com.blazebit.persistence.Keyset; -import com.blazebit.persistence.impl.OrderByExpression; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public interface KeysetLink { - - public void initialize(List orderByExpressions); - - public Keyset getKeyset(); - - public KeysetMode getKeysetMode(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.keyset; + +import java.util.List; + +import com.blazebit.persistence.Keyset; +import com.blazebit.persistence.impl.OrderByExpression; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public interface KeysetLink { + + public void initialize(List orderByExpressions); + + public Keyset getKeyset(); + + public KeysetMode getKeysetMode(); +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetManager.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetManager.java index 7631853760..acb8fc336e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetManager.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetManager.java @@ -1,179 +1,179 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.keyset; - -import java.io.Serializable; -import java.util.List; - -import com.blazebit.persistence.Keyset; -import com.blazebit.persistence.impl.OrderByExpression; -import com.blazebit.persistence.impl.ParameterManager; -import com.blazebit.persistence.impl.ResolvingQueryGenerator; -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class KeysetManager extends AbstractKeysetBuilderEndedListener { - - private static final String KEY_SET_PARAMETER_NAME = "_keysetParameter"; - - private final ResolvingQueryGenerator queryGenerator; - private final ParameterManager parameterManager; - private List orderByExpressions; - - public KeysetManager(ResolvingQueryGenerator queryGenerator, ParameterManager parameterManager) { - this.queryGenerator = queryGenerator; - this.parameterManager = parameterManager; - } - - public boolean hasKeyset() { - return getKeysetLink() != null; - } - - public void initialize(List orderByExpressions) { - this.orderByExpressions = orderByExpressions; - - KeysetLink keysetLink = getKeysetLink(); - // Checks if keyset fits for order by expressions - keysetLink.initialize(orderByExpressions); - } - - public void buildKeysetPredicate(StringBuilder sb) { - int expressionCount = orderByExpressions.size(); - KeysetLink keysetLink = getKeysetLink(); - KeysetMode keysetMode = keysetLink.getKeysetMode(); - Keyset keyset = keysetLink.getKeyset(); - Serializable[] key; - - key = keyset.getTuple(); - - boolean generateEqualPredicate = true; - int brackets = 0; - - boolean conditionalContext = queryGenerator.setConditionalContext(false); - - // We wrap the whole thing in brackets - brackets++; - sb.append('('); - - for (int i = 0; i < expressionCount; i++) { - boolean isNotLast = i + 1 != expressionCount; - - OrderByExpression orderByExpr = orderByExpressions.get(i); - Expression expr = orderByExpr.getExpression(); - - if (orderByExpr.isNullable()) { - boolean isPrevious = keysetMode == KeysetMode.PREVIOUS; - - if (key[i] == null) { - if (orderByExpr.isNullFirst() == isPrevious) { - // Case for previous and null first or not previous and null last - generateEqualPredicate = false; - applyKeysetNullItem(sb, expr, false); - } else { - // Case for previous and null last or not previous and null first - applyKeysetNullItem(sb, expr, true); - } - } else { - if (orderByExpr.isNullFirst() == isPrevious) { - // Case for previous and null first or not previous and null last - sb.append('('); - applyKeysetNotNullableItem(orderByExpr, sb, expr, i, key, keysetMode); - sb.append(" OR "); - applyKeysetNullItem(sb, expr, false); - sb.append(')'); - } else { - // Case for previous and null last or not previous and null first - applyKeysetNotNullableItem(orderByExpr, sb, expr, i, key, keysetMode); - } - } - } else { - applyKeysetNotNullableItem(orderByExpr, sb, expr, i, key, keysetMode); - } - - if (isNotLast) { - if (generateEqualPredicate) { - brackets++; - sb.append(" OR ("); - if (key[i] == null) { - applyKeysetNullItem(sb, expr, false); - } else { - applyKeysetItem(sb, expr, "=", i, key[i]); - } - } - - sb.append(" AND "); - if (i + 2 != expressionCount) { - brackets++; - sb.append('('); - } - - generateEqualPredicate = true; - } - } - - for (int i = 0; i < brackets; i++) { - sb.append(')'); - } - - queryGenerator.setConditionalContext(conditionalContext); - } - - private void applyKeysetNotNullableItem(OrderByExpression orderByExpr, StringBuilder sb, Expression expr, int i, Serializable[] key, KeysetMode keysetMode) { - String operator; - switch (keysetMode) { - case SAME: - operator = orderByExpr.isAscending() ? ">=" : "<="; - break; - case NEXT: - operator = orderByExpr.isAscending() ? ">" : "<"; - break; - case PREVIOUS: - operator = orderByExpr.isAscending() ? "<" : ">"; - break; - default: - throw new IllegalArgumentException("Unknown key set mode: " + keysetMode); - } - - applyKeysetItem(sb, expr, operator, i, key[i]); - } - - private void applyKeysetItem(StringBuilder sb, Expression expr, String operator, int position, Serializable keyElement) { - queryGenerator.setQueryBuffer(sb); - expr.accept(queryGenerator); - sb.append(" "); - sb.append(operator); - sb.append(" :"); - String parameterName = new StringBuilder(KEY_SET_PARAMETER_NAME).append('_').append(position).toString(); - sb.append(parameterName); - parameterManager.addParameterMapping(parameterName, keyElement); - } - - private void applyKeysetNullItem(StringBuilder sb, Expression expr, boolean not) { - queryGenerator.setQueryBuffer(sb); - expr.accept(queryGenerator); - - if (not) { - sb.append(" IS NOT NULL"); - } else { - sb.append(" IS NULL"); - } - } - -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.keyset; + +import java.io.Serializable; +import java.util.List; + +import com.blazebit.persistence.Keyset; +import com.blazebit.persistence.impl.OrderByExpression; +import com.blazebit.persistence.impl.ParameterManager; +import com.blazebit.persistence.impl.ResolvingQueryGenerator; +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class KeysetManager extends AbstractKeysetBuilderEndedListener { + + private static final String KEY_SET_PARAMETER_NAME = "_keysetParameter"; + + private final ResolvingQueryGenerator queryGenerator; + private final ParameterManager parameterManager; + private List orderByExpressions; + + public KeysetManager(ResolvingQueryGenerator queryGenerator, ParameterManager parameterManager) { + this.queryGenerator = queryGenerator; + this.parameterManager = parameterManager; + } + + public boolean hasKeyset() { + return getKeysetLink() != null; + } + + public void initialize(List orderByExpressions) { + this.orderByExpressions = orderByExpressions; + + KeysetLink keysetLink = getKeysetLink(); + // Checks if keyset fits for order by expressions + keysetLink.initialize(orderByExpressions); + } + + public void buildKeysetPredicate(StringBuilder sb) { + int expressionCount = orderByExpressions.size(); + KeysetLink keysetLink = getKeysetLink(); + KeysetMode keysetMode = keysetLink.getKeysetMode(); + Keyset keyset = keysetLink.getKeyset(); + Serializable[] key; + + key = keyset.getTuple(); + + boolean generateEqualPredicate = true; + int brackets = 0; + + boolean conditionalContext = queryGenerator.setConditionalContext(false); + + // We wrap the whole thing in brackets + brackets++; + sb.append('('); + + for (int i = 0; i < expressionCount; i++) { + boolean isNotLast = i + 1 != expressionCount; + + OrderByExpression orderByExpr = orderByExpressions.get(i); + Expression expr = orderByExpr.getExpression(); + + if (orderByExpr.isNullable()) { + boolean isPrevious = keysetMode == KeysetMode.PREVIOUS; + + if (key[i] == null) { + if (orderByExpr.isNullFirst() == isPrevious) { + // Case for previous and null first or not previous and null last + generateEqualPredicate = false; + applyKeysetNullItem(sb, expr, false); + } else { + // Case for previous and null last or not previous and null first + applyKeysetNullItem(sb, expr, true); + } + } else { + if (orderByExpr.isNullFirst() == isPrevious) { + // Case for previous and null first or not previous and null last + sb.append('('); + applyKeysetNotNullableItem(orderByExpr, sb, expr, i, key, keysetMode); + sb.append(" OR "); + applyKeysetNullItem(sb, expr, false); + sb.append(')'); + } else { + // Case for previous and null last or not previous and null first + applyKeysetNotNullableItem(orderByExpr, sb, expr, i, key, keysetMode); + } + } + } else { + applyKeysetNotNullableItem(orderByExpr, sb, expr, i, key, keysetMode); + } + + if (isNotLast) { + if (generateEqualPredicate) { + brackets++; + sb.append(" OR ("); + if (key[i] == null) { + applyKeysetNullItem(sb, expr, false); + } else { + applyKeysetItem(sb, expr, "=", i, key[i]); + } + } + + sb.append(" AND "); + if (i + 2 != expressionCount) { + brackets++; + sb.append('('); + } + + generateEqualPredicate = true; + } + } + + for (int i = 0; i < brackets; i++) { + sb.append(')'); + } + + queryGenerator.setConditionalContext(conditionalContext); + } + + private void applyKeysetNotNullableItem(OrderByExpression orderByExpr, StringBuilder sb, Expression expr, int i, Serializable[] key, KeysetMode keysetMode) { + String operator; + switch (keysetMode) { + case SAME: + operator = orderByExpr.isAscending() ? ">=" : "<="; + break; + case NEXT: + operator = orderByExpr.isAscending() ? ">" : "<"; + break; + case PREVIOUS: + operator = orderByExpr.isAscending() ? "<" : ">"; + break; + default: + throw new IllegalArgumentException("Unknown key set mode: " + keysetMode); + } + + applyKeysetItem(sb, expr, operator, i, key[i]); + } + + private void applyKeysetItem(StringBuilder sb, Expression expr, String operator, int position, Serializable keyElement) { + queryGenerator.setQueryBuffer(sb); + expr.accept(queryGenerator); + sb.append(" "); + sb.append(operator); + sb.append(" :"); + String parameterName = new StringBuilder(KEY_SET_PARAMETER_NAME).append('_').append(position).toString(); + sb.append(parameterName); + parameterManager.addParameterMapping(parameterName, keyElement); + } + + private void applyKeysetNullItem(StringBuilder sb, Expression expr, boolean not) { + queryGenerator.setQueryBuffer(sb); + expr.accept(queryGenerator); + + if (not) { + sb.append(" IS NOT NULL"); + } else { + sb.append(" IS NULL"); + } + } + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetMode.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetMode.java index 13506aed02..f92d7cd75a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetMode.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetMode.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.keyset; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public enum KeysetMode { - - NONE, - SAME, - NEXT, - PREVIOUS; -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.keyset; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public enum KeysetMode { + + NONE, + SAME, + NEXT, + PREVIOUS; +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetPageImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetPageImpl.java index 537ecb9e28..03bc66f341 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetPageImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetPageImpl.java @@ -1,67 +1,67 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.keyset; - -import java.io.Serializable; - -import com.blazebit.persistence.Keyset; -import com.blazebit.persistence.KeysetPage; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class KeysetPageImpl implements KeysetPage { - - private static final long serialVersionUID = 1L; - - private final int firstResult; - private final int maxResults; - private final Keyset lowest; - private final Keyset highest; - - public KeysetPageImpl(int firstResult, int maxResults, Serializable[] lowest, Serializable[] highest) { - this(firstResult, maxResults, new KeysetImpl(lowest), new KeysetImpl(highest)); - } - - public KeysetPageImpl(int firstResult, int maxResults, Keyset lowest, Keyset highest) { - this.firstResult = firstResult; - this.maxResults = maxResults; - this.lowest = lowest; - this.highest = highest; - } - - @Override - public int getFirstResult() { - return firstResult; - } - - @Override - public int getMaxResults() { - return maxResults; - } - - @Override - public Keyset getLowest() { - return lowest; - } - - @Override - public Keyset getHighest() { - return highest; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.keyset; + +import java.io.Serializable; + +import com.blazebit.persistence.Keyset; +import com.blazebit.persistence.KeysetPage; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class KeysetPageImpl implements KeysetPage { + + private static final long serialVersionUID = 1L; + + private final int firstResult; + private final int maxResults; + private final Keyset lowest; + private final Keyset highest; + + public KeysetPageImpl(int firstResult, int maxResults, Serializable[] lowest, Serializable[] highest) { + this(firstResult, maxResults, new KeysetImpl(lowest), new KeysetImpl(highest)); + } + + public KeysetPageImpl(int firstResult, int maxResults, Keyset lowest, Keyset highest) { + this.firstResult = firstResult; + this.maxResults = maxResults; + this.lowest = lowest; + this.highest = highest; + } + + @Override + public int getFirstResult() { + return firstResult; + } + + @Override + public int getMaxResults() { + return maxResults; + } + + @Override + public Keyset getLowest() { + return lowest; + } + + @Override + public Keyset getHighest() { + return highest; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetPaginationHelper.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetPaginationHelper.java index 7df6d4db53..44a676ef1e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetPaginationHelper.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/KeysetPaginationHelper.java @@ -1,84 +1,84 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.keyset; - -import java.io.Serializable; - -import com.blazebit.persistence.Keyset; -import com.blazebit.persistence.KeysetPage; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class KeysetPaginationHelper { - - public static Serializable[] extractKey(Object[] tuple, int offset) { - Serializable[] key = new Serializable[tuple.length - offset]; - System.arraycopy(tuple, offset, key, 0, key.length); - return key; - } - - public static KeysetMode getKeysetMode(KeysetPage keysetPage, int firstRow, int pageSize) { - // a keyset must be given - if (keysetPage == null) { - return KeysetMode.NONE; - } - // The last page size must equal the current page size - if (keysetPage.getMaxResults() != pageSize) { - return KeysetMode.NONE; - } - - int offset = keysetPage.getFirstResult() - firstRow; - - if (offset == pageSize) { - // We went to the previous page - if (isValidKey(keysetPage.getLowest())) { - return KeysetMode.PREVIOUS; - } else { - return KeysetMode.NONE; - } - } else if (offset == -pageSize) { - // We went to the next page - if (isValidKey(keysetPage.getHighest())) { - return KeysetMode.NEXT; - } else { - return KeysetMode.NONE; - } - } else if (offset == 0) { - // Same page again - if (isValidKey(keysetPage.getLowest())) { - return KeysetMode.SAME; - } else { - return KeysetMode.NONE; - } - } else { - // The last key set is away more than one page - return KeysetMode.NONE; - } - } - - private static boolean isValidKey(Keyset keyset) { - if (keyset == null) { - return false; - } - - Serializable[] key = keyset.getTuple(); - return key != null && key.length > 0; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.keyset; + +import java.io.Serializable; + +import com.blazebit.persistence.Keyset; +import com.blazebit.persistence.KeysetPage; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class KeysetPaginationHelper { + + public static Serializable[] extractKey(Object[] tuple, int offset) { + Serializable[] key = new Serializable[tuple.length - offset]; + System.arraycopy(tuple, offset, key, 0, key.length); + return key; + } + + public static KeysetMode getKeysetMode(KeysetPage keysetPage, int firstRow, int pageSize) { + // a keyset must be given + if (keysetPage == null) { + return KeysetMode.NONE; + } + // The last page size must equal the current page size + if (keysetPage.getMaxResults() != pageSize) { + return KeysetMode.NONE; + } + + int offset = keysetPage.getFirstResult() - firstRow; + + if (offset == pageSize) { + // We went to the previous page + if (isValidKey(keysetPage.getLowest())) { + return KeysetMode.PREVIOUS; + } else { + return KeysetMode.NONE; + } + } else if (offset == -pageSize) { + // We went to the next page + if (isValidKey(keysetPage.getHighest())) { + return KeysetMode.NEXT; + } else { + return KeysetMode.NONE; + } + } else if (offset == 0) { + // Same page again + if (isValidKey(keysetPage.getLowest())) { + return KeysetMode.SAME; + } else { + return KeysetMode.NONE; + } + } else { + // The last key set is away more than one page + return KeysetMode.NONE; + } + } + + private static boolean isValidKey(Keyset keyset) { + if (keyset == null) { + return false; + } + + Serializable[] key = keyset.getTuple(); + return key != null && key.length > 0; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/LazyKeysetLink.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/LazyKeysetLink.java index 754fa2baf8..87f82f8169 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/LazyKeysetLink.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/LazyKeysetLink.java @@ -1,74 +1,74 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.keyset; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import com.blazebit.persistence.Keyset; -import com.blazebit.persistence.impl.OrderByExpression; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class LazyKeysetLink extends AbstractKeysetLink { - - private final Map keysetValues; - private Keyset keyset; - - public LazyKeysetLink(Map keysetValues, KeysetMode keysetMode) { - super(keysetMode); - this.keysetValues = keysetValues; - } - - @Override - public void initialize(List orderByExpressions) { - Serializable[] tuple = new Serializable[orderByExpressions.size()]; - - for (int i = 0; i < tuple.length; i++) { - String expressionString = orderByExpressions.get(0).getExpression().toString(); - Object value = keysetValues.get(expressionString); - - if (value == null) { - if (!keysetValues.containsKey(expressionString)) { - throw new IllegalArgumentException("The keyset provided [" + keysetValues - + "] does not contain an entry for the order by expression: " + expressionString); - } - - tuple[i] = null; - } else { - if (!(value instanceof Serializable)) { - throw new IllegalArgumentException("The keyset value [" + value + "] provided for the order by expression [" + expressionString - + "] is not an instance of java.io.Serializable!"); - } - - tuple[i] = (Serializable) value; - } - } - - keyset = new KeysetImpl(tuple); - validate(keyset, orderByExpressions); - } - - @Override - public Keyset getKeyset() { - return keyset; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.keyset; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import com.blazebit.persistence.Keyset; +import com.blazebit.persistence.impl.OrderByExpression; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class LazyKeysetLink extends AbstractKeysetLink { + + private final Map keysetValues; + private Keyset keyset; + + public LazyKeysetLink(Map keysetValues, KeysetMode keysetMode) { + super(keysetMode); + this.keysetValues = keysetValues; + } + + @Override + public void initialize(List orderByExpressions) { + Serializable[] tuple = new Serializable[orderByExpressions.size()]; + + for (int i = 0; i < tuple.length; i++) { + String expressionString = orderByExpressions.get(0).getExpression().toString(); + Object value = keysetValues.get(expressionString); + + if (value == null) { + if (!keysetValues.containsKey(expressionString)) { + throw new IllegalArgumentException("The keyset provided [" + keysetValues + + "] does not contain an entry for the order by expression: " + expressionString); + } + + tuple[i] = null; + } else { + if (!(value instanceof Serializable)) { + throw new IllegalArgumentException("The keyset value [" + value + "] provided for the order by expression [" + expressionString + + "] is not an instance of java.io.Serializable!"); + } + + tuple[i] = (Serializable) value; + } + } + + keyset = new KeysetImpl(tuple); + validate(keyset, orderByExpressions); + } + + @Override + public Keyset getKeyset() { + return keyset; + } +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/SimpleKeysetLink.java b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/SimpleKeysetLink.java index 5255ed206d..c6741b08fa 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/SimpleKeysetLink.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/keyset/SimpleKeysetLink.java @@ -1,52 +1,52 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.keyset; - -import java.util.List; - -import com.blazebit.persistence.Keyset; -import com.blazebit.persistence.impl.OrderByExpression; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public class SimpleKeysetLink extends AbstractKeysetLink { - - private final Keyset keyset; - - public SimpleKeysetLink(Keyset keyset, KeysetMode keysetMode) { - super(keysetMode); - - if (keyset == null) { - throw new NullPointerException("keyset"); - } - - this.keyset = keyset; - } - - @Override - public void initialize(List orderByExpressions) { - validate(keyset, orderByExpressions); - } - - @Override - public Keyset getKeyset() { - return keyset; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.keyset; + +import java.util.List; + +import com.blazebit.persistence.Keyset; +import com.blazebit.persistence.impl.OrderByExpression; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public class SimpleKeysetLink extends AbstractKeysetLink { + + private final Keyset keyset; + + public SimpleKeysetLink(Keyset keyset, KeysetMode keysetMode) { + super(keysetMode); + + if (keyset == null) { + throw new NullPointerException("keyset"); + } + + this.keyset = keyset; + } + + @Override + public void initialize(List orderByExpressions) { + validate(keyset, orderByExpressions); + } + + @Override + public Keyset getKeyset() { + return keyset; + } +} diff --git a/core/impl/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider b/core/impl/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider index a898e4643d..a379cab48f 100644 --- a/core/impl/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider +++ b/core/impl/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider @@ -1 +1 @@ -com.blazebit.persistence.impl.CriteriaBuilderConfigurationProviderImpl +com.blazebit.persistence.impl.CriteriaBuilderConfigurationProviderImpl diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/AbstractExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/AbstractExpression.java index 11d14e7640..8133297597 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/AbstractExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/AbstractExpression.java @@ -1,38 +1,38 @@ -/* - * Copyright 2015 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -import com.blazebit.persistence.impl.SimpleQueryGenerator; - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public abstract class AbstractExpression implements Expression { - - @Override - public abstract Expression clone(); - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - SimpleQueryGenerator generator = new SimpleQueryGenerator(); - generator.setQueryBuffer(sb); - accept(generator); - return sb.toString(); - } -} +/* + * Copyright 2015 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +import com.blazebit.persistence.impl.SimpleQueryGenerator; + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public abstract class AbstractExpression implements Expression { + + @Override + public abstract Expression clone(); + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + SimpleQueryGenerator generator = new SimpleQueryGenerator(); + generator.setQueryBuffer(sb); + accept(generator); + return sb.toString(); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ArrayExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ArrayExpression.java index fab6aa27c0..882db2c4aa 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ArrayExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ArrayExpression.java @@ -1,83 +1,83 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class ArrayExpression extends AbstractExpression implements PathElementExpression { - - private final PropertyExpression base; - private final Expression index; - - public ArrayExpression(PropertyExpression base, Expression index) { - this.base = base; - this.index = index; - } - - @Override - public ArrayExpression clone() { - return new ArrayExpression(base.clone(), index.clone()); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public PropertyExpression getBase() { - return base; - } - - public Expression getIndex() { - return index; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 61 * hash + (this.base != null ? this.base.hashCode() : 0); - hash = 61 * hash + (this.index != null ? this.index.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ArrayExpression other = (ArrayExpression) obj; - if (this.base != other.base && (this.base == null || !this.base.equals(other.base))) { - return false; - } - if (this.index != other.index && (this.index == null || !this.index.equals(other.index))) { - return false; - } - return true; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class ArrayExpression extends AbstractExpression implements PathElementExpression { + + private final PropertyExpression base; + private final Expression index; + + public ArrayExpression(PropertyExpression base, Expression index) { + this.base = base; + this.index = index; + } + + @Override + public ArrayExpression clone() { + return new ArrayExpression(base.clone(), index.clone()); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public PropertyExpression getBase() { + return base; + } + + public Expression getIndex() { + return index; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 61 * hash + (this.base != null ? this.base.hashCode() : 0); + hash = 61 * hash + (this.index != null ? this.index.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ArrayExpression other = (ArrayExpression) obj; + if (this.base != other.base && (this.base == null || !this.base.equals(other.base))) { + return false; + } + if (this.index != other.index && (this.index == null || !this.index.equals(other.index))) { + return false; + } + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/CompositeExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/CompositeExpression.java index 9eb8160b44..dbcb91a7d9 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/CompositeExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/CompositeExpression.java @@ -1,132 +1,132 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class CompositeExpression extends AbstractExpression { - - private final List expressions; - - public CompositeExpression(List expressions) { - this.expressions = expressions; - } - - @Override - public CompositeExpression clone() { - int size = expressions.size(); - List newExpressions = new ArrayList(size); - - for (int i = 0; i < size; i++) { - newExpressions.add(expressions.get(i).clone()); - } - - return new CompositeExpression(newExpressions); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public List getExpressions() { - return expressions; - } - - public void append(Expression expr) { - Expression lastExpr; - if (expr instanceof CompositeExpression) { - CompositeExpression composite = (CompositeExpression) expr; - List expressions = composite.getExpressions(); - int size = expressions.size(); - for (int i = 0; i < size; i++) { - append(expressions.get(i)); - } - } else if (!expressions.isEmpty() && expr instanceof FooExpression - && (lastExpr = expressions.get(expressions.size() - 1)) instanceof FooExpression) { - ((FooExpression) lastExpr).getStringBuilder().append(((FooExpression) expr).getStringBuilder()); - } else { - expressions.add(expr); - } - } - - public void prepend(String str) { - if (!str.isEmpty()) { - Expression firstExpr; - if (!expressions.isEmpty() && (firstExpr = expressions.get(0)) instanceof FooExpression) { - ((FooExpression) firstExpr).getStringBuilder().insert(0, str); - } else { - expressions.add(0, new FooExpression(str)); - } - } - } - - public void append(String str) { - if (str != null && !str.isEmpty()) { - Expression lastExpr; - if (!expressions.isEmpty() && (lastExpr = expressions.get(expressions.size() - 1)) instanceof FooExpression) { - ((FooExpression) lastExpr).getStringBuilder().append(str); - } else { - expressions.add(new FooExpression(str)); - } - } - } - - public void append(StringBuilder sb) { - if (sb != null && sb.length() > 0) { - Expression lastExpr; - if (!expressions.isEmpty() && (lastExpr = expressions.get(expressions.size() - 1)) instanceof FooExpression) { - ((FooExpression) lastExpr).getStringBuilder().append(sb); - } else { - expressions.add(new FooExpression(sb)); - } - } - } - - @Override - public int hashCode() { - int hash = 7; - hash = 61 * hash + (this.expressions != null ? this.expressions.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final CompositeExpression other = (CompositeExpression) obj; - if (this.expressions != other.expressions && (this.expressions == null || !this.expressions.equals(other.expressions))) { - return false; - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class CompositeExpression extends AbstractExpression { + + private final List expressions; + + public CompositeExpression(List expressions) { + this.expressions = expressions; + } + + @Override + public CompositeExpression clone() { + int size = expressions.size(); + List newExpressions = new ArrayList(size); + + for (int i = 0; i < size; i++) { + newExpressions.add(expressions.get(i).clone()); + } + + return new CompositeExpression(newExpressions); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public List getExpressions() { + return expressions; + } + + public void append(Expression expr) { + Expression lastExpr; + if (expr instanceof CompositeExpression) { + CompositeExpression composite = (CompositeExpression) expr; + List expressions = composite.getExpressions(); + int size = expressions.size(); + for (int i = 0; i < size; i++) { + append(expressions.get(i)); + } + } else if (!expressions.isEmpty() && expr instanceof FooExpression + && (lastExpr = expressions.get(expressions.size() - 1)) instanceof FooExpression) { + ((FooExpression) lastExpr).getStringBuilder().append(((FooExpression) expr).getStringBuilder()); + } else { + expressions.add(expr); + } + } + + public void prepend(String str) { + if (!str.isEmpty()) { + Expression firstExpr; + if (!expressions.isEmpty() && (firstExpr = expressions.get(0)) instanceof FooExpression) { + ((FooExpression) firstExpr).getStringBuilder().insert(0, str); + } else { + expressions.add(0, new FooExpression(str)); + } + } + } + + public void append(String str) { + if (str != null && !str.isEmpty()) { + Expression lastExpr; + if (!expressions.isEmpty() && (lastExpr = expressions.get(expressions.size() - 1)) instanceof FooExpression) { + ((FooExpression) lastExpr).getStringBuilder().append(str); + } else { + expressions.add(new FooExpression(str)); + } + } + } + + public void append(StringBuilder sb) { + if (sb != null && sb.length() > 0) { + Expression lastExpr; + if (!expressions.isEmpty() && (lastExpr = expressions.get(expressions.size() - 1)) instanceof FooExpression) { + ((FooExpression) lastExpr).getStringBuilder().append(sb); + } else { + expressions.add(new FooExpression(sb)); + } + } + } + + @Override + public int hashCode() { + int hash = 7; + hash = 61 * hash + (this.expressions != null ? this.expressions.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CompositeExpression other = (CompositeExpression) obj; + if (this.expressions != other.expressions && (this.expressions == null || !this.expressions.equals(other.expressions))) { + return false; + } + return true; + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ExpressionFactoryImpl.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ExpressionFactoryImpl.java index 3bd19edb8c..de94e20afd 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ExpressionFactoryImpl.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ExpressionFactoryImpl.java @@ -1,49 +1,49 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -import java.util.Set; - -import com.blazebit.persistence.parser.JPQLSelectExpressionParser; - -import org.antlr.v4.runtime.ParserRuleContext; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public final class ExpressionFactoryImpl extends AbstractExpressionFactory { - - private final RuleInvoker simpleExpressionRuleInvoker = new RuleInvoker() { - - @Override - public ParserRuleContext invokeRule(JPQLSelectExpressionParser parser) { - return parser.parseSimpleExpression(); - } - }; - - public ExpressionFactoryImpl(Set aggregateFunctions) { - super(aggregateFunctions); - } - - @Override - protected RuleInvoker getSimpleExpressionRuleInvoker() { - return simpleExpressionRuleInvoker; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +import java.util.Set; + +import com.blazebit.persistence.parser.JPQLSelectExpressionParser; + +import org.antlr.v4.runtime.ParserRuleContext; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public final class ExpressionFactoryImpl extends AbstractExpressionFactory { + + private final RuleInvoker simpleExpressionRuleInvoker = new RuleInvoker() { + + @Override + public ParserRuleContext invokeRule(JPQLSelectExpressionParser parser) { + return parser.parseSimpleExpression(); + } + }; + + public ExpressionFactoryImpl(Set aggregateFunctions) { + super(aggregateFunctions); + } + + @Override + protected RuleInvoker getSimpleExpressionRuleInvoker() { + return simpleExpressionRuleInvoker; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/FooExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/FooExpression.java index 42da0b4476..82af0efae7 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/FooExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/FooExpression.java @@ -1,83 +1,83 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class FooExpression extends AbstractExpression { - - private final StringBuilder stringBuilder; - - public FooExpression(CharSequence string) { - this.stringBuilder = new StringBuilder(string); - } - - public FooExpression(StringBuilder sb) { - this.stringBuilder = sb; - } - - @Override - public FooExpression clone() { - return new FooExpression(stringBuilder); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - StringBuilder getStringBuilder() { - return stringBuilder; - } - - @Override - public String toString() { - return stringBuilder.toString(); - } - - @Override - public int hashCode() { - int hash = 7; - hash = 19 * hash + (this.stringBuilder.toString() != null ? this.stringBuilder.toString().hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final FooExpression other = (FooExpression) obj; - if (this.stringBuilder != other.stringBuilder - && (this.stringBuilder == null || !this.stringBuilder.toString().equals(other.stringBuilder.toString()))) { - return false; - } - return true; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class FooExpression extends AbstractExpression { + + private final StringBuilder stringBuilder; + + public FooExpression(CharSequence string) { + this.stringBuilder = new StringBuilder(string); + } + + public FooExpression(StringBuilder sb) { + this.stringBuilder = sb; + } + + @Override + public FooExpression clone() { + return new FooExpression(stringBuilder); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + StringBuilder getStringBuilder() { + return stringBuilder; + } + + @Override + public String toString() { + return stringBuilder.toString(); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 19 * hash + (this.stringBuilder.toString() != null ? this.stringBuilder.toString().hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final FooExpression other = (FooExpression) obj; + if (this.stringBuilder != other.stringBuilder + && (this.stringBuilder == null || !this.stringBuilder.toString().equals(other.stringBuilder.toString()))) { + return false; + } + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/FunctionExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/FunctionExpression.java index f7cc9c6531..a1a090ac01 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/FunctionExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/FunctionExpression.java @@ -1,95 +1,95 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class FunctionExpression extends AbstractExpression { - - protected final String functionName; - protected List expressions; - - @SuppressWarnings("unchecked") - public FunctionExpression(String functionName, List expressions) { - this.functionName = functionName; - this.expressions = (List) expressions; - } - - @Override - public FunctionExpression clone() { - int size = expressions.size(); - List newExpressions = new ArrayList(size); - - for (int i = 0; i < size; i++) { - newExpressions.add(expressions.get(i).clone()); - } - - return new FunctionExpression(functionName, newExpressions); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public String getFunctionName() { - return functionName; - } - - public List getExpressions() { - return expressions; - } - - public void setExpressions(List expressions) { - this.expressions = expressions; - } - - @Override - public int hashCode() { - int hash = 7; - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final FunctionExpression other = (FunctionExpression) obj; - if ((this.functionName == null) ? (other.functionName != null) : !this.functionName.equals(other.functionName)) { - return false; - } - if (this.expressions != other.expressions && (this.expressions == null || !this.expressions.equals(other.expressions))) { - return false; - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class FunctionExpression extends AbstractExpression { + + protected final String functionName; + protected List expressions; + + @SuppressWarnings("unchecked") + public FunctionExpression(String functionName, List expressions) { + this.functionName = functionName; + this.expressions = (List) expressions; + } + + @Override + public FunctionExpression clone() { + int size = expressions.size(); + List newExpressions = new ArrayList(size); + + for (int i = 0; i < size; i++) { + newExpressions.add(expressions.get(i).clone()); + } + + return new FunctionExpression(functionName, newExpressions); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public String getFunctionName() { + return functionName; + } + + public List getExpressions() { + return expressions; + } + + public void setExpressions(List expressions) { + this.expressions = expressions; + } + + @Override + public int hashCode() { + int hash = 7; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final FunctionExpression other = (FunctionExpression) obj; + if ((this.functionName == null) ? (other.functionName != null) : !this.functionName.equals(other.functionName)) { + return false; + } + if (this.expressions != other.expressions && (this.expressions == null || !this.expressions.equals(other.expressions))) { + return false; + } + return true; + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/GeneralCaseExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/GeneralCaseExpression.java index 15891793e1..344ab28a58 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/GeneralCaseExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/GeneralCaseExpression.java @@ -1,101 +1,101 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.expression; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class GeneralCaseExpression extends AbstractExpression { - - protected final List whenClauses; - protected Expression defaultExpr; - - public GeneralCaseExpression(List whenClauses, Expression defaultExpr) { - this.whenClauses = whenClauses; - this.defaultExpr = defaultExpr; - } - - @Override - public GeneralCaseExpression clone() { - int size = whenClauses.size(); - List newWhenClauses = new ArrayList(size); - - for (int i = 0; i < size; i++) { - newWhenClauses.add(whenClauses.get(i).clone()); - } - - if (defaultExpr == null) { - return new GeneralCaseExpression(whenClauses, null); - } else { - return new GeneralCaseExpression(newWhenClauses, defaultExpr.clone()); - } - } - - public List getWhenClauses() { - return whenClauses; - } - - public Expression getDefaultExpr() { - return defaultExpr; - } - - public void setDefaultExpr(Expression defaultExpr) { - this.defaultExpr = defaultExpr; - } - - @Override - public void accept(Expression.Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - @Override - public int hashCode() { - int hash = 5; - hash = 47 * hash + (this.whenClauses != null ? this.whenClauses.hashCode() : 0); - hash = 47 * hash + (this.defaultExpr != null ? this.defaultExpr.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final GeneralCaseExpression other = (GeneralCaseExpression) obj; - if (this.whenClauses != other.whenClauses && (this.whenClauses == null || !this.whenClauses.equals(other.whenClauses))) { - return false; - } - if (this.defaultExpr != other.defaultExpr && (this.defaultExpr == null || !this.defaultExpr.equals(other.defaultExpr))) { - return false; - } - return true; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.expression; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class GeneralCaseExpression extends AbstractExpression { + + protected final List whenClauses; + protected Expression defaultExpr; + + public GeneralCaseExpression(List whenClauses, Expression defaultExpr) { + this.whenClauses = whenClauses; + this.defaultExpr = defaultExpr; + } + + @Override + public GeneralCaseExpression clone() { + int size = whenClauses.size(); + List newWhenClauses = new ArrayList(size); + + for (int i = 0; i < size; i++) { + newWhenClauses.add(whenClauses.get(i).clone()); + } + + if (defaultExpr == null) { + return new GeneralCaseExpression(whenClauses, null); + } else { + return new GeneralCaseExpression(newWhenClauses, defaultExpr.clone()); + } + } + + public List getWhenClauses() { + return whenClauses; + } + + public Expression getDefaultExpr() { + return defaultExpr; + } + + public void setDefaultExpr(Expression defaultExpr) { + this.defaultExpr = defaultExpr; + } + + @Override + public void accept(Expression.Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + @Override + public int hashCode() { + int hash = 5; + hash = 47 * hash + (this.whenClauses != null ? this.whenClauses.hashCode() : 0); + hash = 47 * hash + (this.defaultExpr != null ? this.defaultExpr.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final GeneralCaseExpression other = (GeneralCaseExpression) obj; + if (this.whenClauses != other.whenClauses && (this.whenClauses == null || !this.whenClauses.equals(other.whenClauses))) { + return false; + } + if (this.defaultExpr != other.defaultExpr && (this.defaultExpr == null || !this.defaultExpr.equals(other.defaultExpr))) { + return false; + } + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/LiteralExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/LiteralExpression.java index 9861a41316..05d8151f3d 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/LiteralExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/LiteralExpression.java @@ -1,92 +1,92 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @since 1.0.1 - */ -public class LiteralExpression extends AbstractExpression { - - private final String wrapperFunction; - private final String literal; - - public LiteralExpression(String wrapperFunction, String literal) { - this.wrapperFunction = wrapperFunction; - this.literal = literal; - } - - @Override - public LiteralExpression clone() { - return new LiteralExpression(wrapperFunction, literal); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public String getWrapperFunction() { - return wrapperFunction; - } - - public String getLiteral() { - return literal; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(wrapperFunction); - sb.append('('); - sb.append(literal); - sb.append(')'); - return sb.toString(); - } - - @Override - public int hashCode() { - int hash = 3; - hash = 67 * hash + (this.wrapperFunction != null ? this.wrapperFunction.hashCode() : 0); - hash = 67 * hash + (this.literal != null ? this.literal.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final LiteralExpression other = (LiteralExpression) obj; - if ((this.wrapperFunction == null) ? (other.wrapperFunction != null) : !this.wrapperFunction.equals(other.wrapperFunction)) { - return false; - } - if ((this.literal == null) ? (other.literal != null) : !this.literal.equals(other.literal)) { - return false; - } - return true; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @since 1.0.1 + */ +public class LiteralExpression extends AbstractExpression { + + private final String wrapperFunction; + private final String literal; + + public LiteralExpression(String wrapperFunction, String literal) { + this.wrapperFunction = wrapperFunction; + this.literal = literal; + } + + @Override + public LiteralExpression clone() { + return new LiteralExpression(wrapperFunction, literal); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public String getWrapperFunction() { + return wrapperFunction; + } + + public String getLiteral() { + return literal; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(wrapperFunction); + sb.append('('); + sb.append(literal); + sb.append(')'); + return sb.toString(); + } + + @Override + public int hashCode() { + int hash = 3; + hash = 67 * hash + (this.wrapperFunction != null ? this.wrapperFunction.hashCode() : 0); + hash = 67 * hash + (this.literal != null ? this.literal.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final LiteralExpression other = (LiteralExpression) obj; + if ((this.wrapperFunction == null) ? (other.wrapperFunction != null) : !this.wrapperFunction.equals(other.wrapperFunction)) { + return false; + } + if ((this.literal == null) ? (other.literal != null) : !this.literal.equals(other.literal)) { + return false; + } + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/NullExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/NullExpression.java index 765f92f27a..2a1bbd9143 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/NullExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/NullExpression.java @@ -1,55 +1,55 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @since 1.0.1 - */ -public class NullExpression extends AbstractExpression { - - @Override - public NullExpression clone() { - return new NullExpression(); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - @Override - public String toString() { - return "NULL"; - } - - @Override - public boolean equals(Object obj) { - return obj instanceof NullExpression; - } - - @Override - public int hashCode() { - return 31; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @since 1.0.1 + */ +public class NullExpression extends AbstractExpression { + + @Override + public NullExpression clone() { + return new NullExpression(); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return "NULL"; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof NullExpression; + } + + @Override + public int hashCode() { + return 31; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ParameterExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ParameterExpression.java index c79310411b..596783b189 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ParameterExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/ParameterExpression.java @@ -1,92 +1,92 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class ParameterExpression extends AbstractExpression { - - private String name; - private Object value; - - public ParameterExpression(String name) { - this.name = name; - } - - public ParameterExpression(String name, Object value) { - this.name = name; - this.value = value; - } - - @Override - public ParameterExpression clone() { - return new ParameterExpression(name); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Object getValue() { - return value; - } - - @Override - public String toString() { - return ":" + name; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ParameterExpression other = (ParameterExpression) obj; - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - return true; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class ParameterExpression extends AbstractExpression { + + private String name; + private Object value; + + public ParameterExpression(String name) { + this.name = name; + } + + public ParameterExpression(String name, Object value) { + this.name = name; + this.value = value; + } + + @Override + public ParameterExpression clone() { + return new ParameterExpression(name); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Object getValue() { + return value; + } + + @Override + public String toString() { + return ":" + name; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ParameterExpression other = (ParameterExpression) obj; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathElementExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathElementExpression.java index 24e7fede7e..5f0de05036 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathElementExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathElementExpression.java @@ -1,27 +1,27 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public interface PathElementExpression extends Expression { - - public PathElementExpression clone(); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public interface PathElementExpression extends Expression { + + public PathElementExpression clone(); +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathExpression.java index 5ca2782065..d99dfd9f36 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathExpression.java @@ -1,159 +1,159 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class PathExpression extends AbstractExpression implements Expression { - - private final List pathProperties; - private PathReference pathReference; - private boolean usedInCollectionFunction = false; - private boolean collectionKeyPath; - - public PathExpression() { - this(new ArrayList(), false); - } - - public PathExpression(List pathProperties) { - this(pathProperties, false); - } - - public PathExpression(List pathProperties, boolean isCollectionKeyPath) { - this.pathProperties = pathProperties; - this.collectionKeyPath = isCollectionKeyPath; - } - - public PathExpression(List pathProperties, PathReference pathReference, boolean usedInCollectionFunction, boolean collectionKeyPath) { - this.pathProperties = pathProperties; - this.pathReference = pathReference; - this.usedInCollectionFunction = usedInCollectionFunction; - this.collectionKeyPath = collectionKeyPath; - } - - @Override - public Expression clone() { - int size = pathProperties.size(); - List newPathProperties = new ArrayList(size); - - for (int i = 0; i < size; i++) { - newPathProperties.add(pathProperties.get(i).clone()); - } - - return new PathExpression(newPathProperties, pathReference, usedInCollectionFunction, collectionKeyPath); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public List getExpressions() { - return pathProperties; - } - - public PathReference getPathReference() { - return pathReference; - } - - public void setPathReference(PathReference pathReference) { - this.pathReference = pathReference; - } - - public Object getBaseNode() { - if (pathReference == null) { - return null; - } - - return pathReference.getBaseNode(); - } - - public String getField() { - if (pathReference == null) { - return null; - } - - return pathReference.getField(); - } - - public boolean isUsedInCollectionFunction() { - return usedInCollectionFunction; - } - - public void setUsedInCollectionFunction(boolean collectionValued) { - this.usedInCollectionFunction = collectionValued; - } - - public String getPath() { - return toString(); - } - - public boolean isCollectionKeyPath() { - return collectionKeyPath; - } - - public void setCollectionKeyPath(boolean collectionKeyPath) { - this.collectionKeyPath = collectionKeyPath; - } - - /* - * The following equals and hashCode implementation makes it possible that expressions which have different path properties but - * reference the same object, are equal. - */ - @Override - public int hashCode() { - int hash = 3; - if (this.pathReference != null) { - hash = 31 * hash + (this.pathReference != null ? this.pathReference.hashCode() : 0); - } else { - hash = 31 * hash + (this.pathProperties != null ? this.pathProperties.hashCode() : 0); - } - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final PathExpression other = (PathExpression) obj; - if (this.pathReference != null|| other.pathReference != null) { - if (this.pathReference != other.pathReference && (this.pathReference == null || !this.pathReference.equals(other.pathReference))) { - return false; - } - } else { - if (this.pathProperties != other.pathProperties && (this.pathProperties == null || !this.pathProperties.equals(other.pathProperties))) { - return false; - } - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class PathExpression extends AbstractExpression implements Expression { + + private final List pathProperties; + private PathReference pathReference; + private boolean usedInCollectionFunction = false; + private boolean collectionKeyPath; + + public PathExpression() { + this(new ArrayList(), false); + } + + public PathExpression(List pathProperties) { + this(pathProperties, false); + } + + public PathExpression(List pathProperties, boolean isCollectionKeyPath) { + this.pathProperties = pathProperties; + this.collectionKeyPath = isCollectionKeyPath; + } + + public PathExpression(List pathProperties, PathReference pathReference, boolean usedInCollectionFunction, boolean collectionKeyPath) { + this.pathProperties = pathProperties; + this.pathReference = pathReference; + this.usedInCollectionFunction = usedInCollectionFunction; + this.collectionKeyPath = collectionKeyPath; + } + + @Override + public Expression clone() { + int size = pathProperties.size(); + List newPathProperties = new ArrayList(size); + + for (int i = 0; i < size; i++) { + newPathProperties.add(pathProperties.get(i).clone()); + } + + return new PathExpression(newPathProperties, pathReference, usedInCollectionFunction, collectionKeyPath); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public List getExpressions() { + return pathProperties; + } + + public PathReference getPathReference() { + return pathReference; + } + + public void setPathReference(PathReference pathReference) { + this.pathReference = pathReference; + } + + public Object getBaseNode() { + if (pathReference == null) { + return null; + } + + return pathReference.getBaseNode(); + } + + public String getField() { + if (pathReference == null) { + return null; + } + + return pathReference.getField(); + } + + public boolean isUsedInCollectionFunction() { + return usedInCollectionFunction; + } + + public void setUsedInCollectionFunction(boolean collectionValued) { + this.usedInCollectionFunction = collectionValued; + } + + public String getPath() { + return toString(); + } + + public boolean isCollectionKeyPath() { + return collectionKeyPath; + } + + public void setCollectionKeyPath(boolean collectionKeyPath) { + this.collectionKeyPath = collectionKeyPath; + } + + /* + * The following equals and hashCode implementation makes it possible that expressions which have different path properties but + * reference the same object, are equal. + */ + @Override + public int hashCode() { + int hash = 3; + if (this.pathReference != null) { + hash = 31 * hash + (this.pathReference != null ? this.pathReference.hashCode() : 0); + } else { + hash = 31 * hash + (this.pathProperties != null ? this.pathProperties.hashCode() : 0); + } + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PathExpression other = (PathExpression) obj; + if (this.pathReference != null|| other.pathReference != null) { + if (this.pathReference != other.pathReference && (this.pathReference == null || !this.pathReference.equals(other.pathReference))) { + return false; + } + } else { + if (this.pathProperties != other.pathProperties && (this.pathProperties == null || !this.pathProperties.equals(other.pathProperties))) { + return false; + } + } + return true; + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathReference.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathReference.java index feffb070b9..7468ce06a3 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathReference.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PathReference.java @@ -1,16 +1,16 @@ -package com.blazebit.persistence.impl.expression; - -/** - * TODO: documentation - * - * @author Christian Beikov - * @since 1.1.0 - * - */ -public interface PathReference { - - // Although this node will always be a JoinNode we will use casting at use site to be able to reuse the parser - public Object getBaseNode(); - - public String getField(); -} +package com.blazebit.persistence.impl.expression; + +/** + * TODO: documentation + * + * @author Christian Beikov + * @since 1.1.0 + * + */ +public interface PathReference { + + // Although this node will always be a JoinNode we will use casting at use site to be able to reuse the parser + public Object getBaseNode(); + + public String getField(); +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PropertyExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PropertyExpression.java index ec3afaee02..55c1707557 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PropertyExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/PropertyExpression.java @@ -1,79 +1,79 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class PropertyExpression extends AbstractExpression implements PathElementExpression { - - private final String property; - - public PropertyExpression(String property) { - this.property = property; - } - - @Override - public PropertyExpression clone() { - // We can do this since this is immutable - return this; - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public String getProperty() { - return property; - } - - @Override - public String toString() { - return property; - } - - @Override - public int hashCode() { - int hash = 5; - hash = 29 * hash + (this.property != null ? this.property.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final PropertyExpression other = (PropertyExpression) obj; - if ((this.property == null) ? (other.property != null) : !this.property.equals(other.property)) { - return false; - } - return true; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class PropertyExpression extends AbstractExpression implements PathElementExpression { + + private final String property; + + public PropertyExpression(String property) { + this.property = property; + } + + @Override + public PropertyExpression clone() { + // We can do this since this is immutable + return this; + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public String getProperty() { + return property; + } + + @Override + public String toString() { + return property; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 29 * hash + (this.property != null ? this.property.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PropertyExpression other = (PropertyExpression) obj; + if ((this.property == null) ? (other.property != null) : !this.property.equals(other.property)) { + return false; + } + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimpleCachingExpressionFactory.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimpleCachingExpressionFactory.java index 83849efc7e..46e8570a24 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimpleCachingExpressionFactory.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimpleCachingExpressionFactory.java @@ -1,102 +1,102 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -import java.util.Arrays; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * - * @author cpbec - */ -public class SimpleCachingExpressionFactory extends AbstractCachingExpressionFactory { - - private final ConcurrentMap> cacheManager; - - public SimpleCachingExpressionFactory(ExpressionFactory delegate) { - super(delegate); - this.cacheManager = new ConcurrentHashMap>(); - } - - @Override - protected E getOrDefault(String cacheName, String cacheKey, Supplier defaultSupplier) { - return getOrDefault(cacheName, (Object) cacheKey, defaultSupplier); - } - - @Override - protected E getOrDefault(String cacheName, Object[] cacheKey, Supplier defaultSupplier) { - return getOrDefault(cacheName, (Object) new ObjectArrayCacheKey(cacheKey), defaultSupplier); - } - - @SuppressWarnings("unchecked") - private E getOrDefault(String cacheName, Object cacheKey, Supplier defaultSupplier) { - ConcurrentMap cache = cacheManager.get(cacheName); - - if (cache == null) { - cache = new ConcurrentHashMap(); - ConcurrentMap oldCache = cacheManager.putIfAbsent(cacheName, cache); - - if (oldCache != null) { - cache = oldCache; - } - } - - E expr = (E) cache.get(cacheKey); - - if (expr == null) { - expr = defaultSupplier.get(); - E oldExpr = (E) cache.putIfAbsent(cacheKey, expr); - - if (oldExpr != null) { - expr = oldExpr; - } - } - - return (E) expr.clone(); - } - - private static final class ObjectArrayCacheKey { - private final Object[] value; - - public ObjectArrayCacheKey(Object[] value) { - this.value = value; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(value); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ObjectArrayCacheKey other = (ObjectArrayCacheKey) obj; - if (!Arrays.equals(value, other.value)) - return false; - return true; - } - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +import java.util.Arrays; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * + * @author cpbec + */ +public class SimpleCachingExpressionFactory extends AbstractCachingExpressionFactory { + + private final ConcurrentMap> cacheManager; + + public SimpleCachingExpressionFactory(ExpressionFactory delegate) { + super(delegate); + this.cacheManager = new ConcurrentHashMap>(); + } + + @Override + protected E getOrDefault(String cacheName, String cacheKey, Supplier defaultSupplier) { + return getOrDefault(cacheName, (Object) cacheKey, defaultSupplier); + } + + @Override + protected E getOrDefault(String cacheName, Object[] cacheKey, Supplier defaultSupplier) { + return getOrDefault(cacheName, (Object) new ObjectArrayCacheKey(cacheKey), defaultSupplier); + } + + @SuppressWarnings("unchecked") + private E getOrDefault(String cacheName, Object cacheKey, Supplier defaultSupplier) { + ConcurrentMap cache = cacheManager.get(cacheName); + + if (cache == null) { + cache = new ConcurrentHashMap(); + ConcurrentMap oldCache = cacheManager.putIfAbsent(cacheName, cache); + + if (oldCache != null) { + cache = oldCache; + } + } + + E expr = (E) cache.get(cacheKey); + + if (expr == null) { + expr = defaultSupplier.get(); + E oldExpr = (E) cache.putIfAbsent(cacheKey, expr); + + if (oldExpr != null) { + expr = oldExpr; + } + } + + return (E) expr.clone(); + } + + private static final class ObjectArrayCacheKey { + private final Object[] value; + + public ObjectArrayCacheKey(Object[] value) { + this.value = value; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(value); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ObjectArrayCacheKey other = (ObjectArrayCacheKey) obj; + if (!Arrays.equals(value, other.value)) + return false; + return true; + } + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimpleCaseExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimpleCaseExpression.java index a77bc95df0..0cbbc91ed9 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimpleCaseExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimpleCaseExpression.java @@ -1,98 +1,98 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.expression; - -import com.blazebit.persistence.impl.SimpleQueryGenerator; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Moritz Becker - */ -public class SimpleCaseExpression extends GeneralCaseExpression { - - private final Expression caseOperand; - - public SimpleCaseExpression(Expression caseOperand, List whenClauses, Expression defaultExpr) { - super(whenClauses, defaultExpr); - this.caseOperand = caseOperand; - } - - @Override - public SimpleCaseExpression clone() { - int size = whenClauses.size(); - List newWhenClauses = new ArrayList(size); - - for (int i = 0; i < size; i++) { - newWhenClauses.add(whenClauses.get(i).clone()); - } - - if (defaultExpr == null) { - return new SimpleCaseExpression(caseOperand.clone(), whenClauses, null); - } else { - return new SimpleCaseExpression(caseOperand.clone(), newWhenClauses, defaultExpr.clone()); - } - } - - public Expression getCaseOperand() { - return caseOperand; - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - @Override - public int hashCode() { - int hash = super.hashCode(); - hash = 89 * hash + (this.caseOperand != null ? this.caseOperand.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final SimpleCaseExpression other = (SimpleCaseExpression) obj; - if (!super.equals(other)) { - return false; - } else if (this.caseOperand != other.caseOperand && (this.caseOperand == null || !this.caseOperand.equals(other.caseOperand))) { - return false; - } - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - SimpleQueryGenerator generator = new SimpleQueryGenerator(); - generator.setQueryBuffer(sb); - generator.visit(this); - return sb.toString(); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.expression; + +import com.blazebit.persistence.impl.SimpleQueryGenerator; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author Moritz Becker + */ +public class SimpleCaseExpression extends GeneralCaseExpression { + + private final Expression caseOperand; + + public SimpleCaseExpression(Expression caseOperand, List whenClauses, Expression defaultExpr) { + super(whenClauses, defaultExpr); + this.caseOperand = caseOperand; + } + + @Override + public SimpleCaseExpression clone() { + int size = whenClauses.size(); + List newWhenClauses = new ArrayList(size); + + for (int i = 0; i < size; i++) { + newWhenClauses.add(whenClauses.get(i).clone()); + } + + if (defaultExpr == null) { + return new SimpleCaseExpression(caseOperand.clone(), whenClauses, null); + } else { + return new SimpleCaseExpression(caseOperand.clone(), newWhenClauses, defaultExpr.clone()); + } + } + + public Expression getCaseOperand() { + return caseOperand; + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 89 * hash + (this.caseOperand != null ? this.caseOperand.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final SimpleCaseExpression other = (SimpleCaseExpression) obj; + if (!super.equals(other)) { + return false; + } else if (this.caseOperand != other.caseOperand && (this.caseOperand == null || !this.caseOperand.equals(other.caseOperand))) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + SimpleQueryGenerator generator = new SimpleQueryGenerator(); + generator.setQueryBuffer(sb); + generator.visit(this); + return sb.toString(); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimplePathReference.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimplePathReference.java index fdf2fa4a0a..b6626b67d5 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimplePathReference.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SimplePathReference.java @@ -1,55 +1,55 @@ -package com.blazebit.persistence.impl.expression; - - -public class SimplePathReference implements PathReference { - - private final Object baseNode; - private final String field; - - public SimplePathReference(Object baseNode, String field) { - this.baseNode = baseNode; - this.field = field; - } - - @Override - public Object getBaseNode() { - return baseNode; - } - - @Override - public String getField() { - return field; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((baseNode == null) ? 0 : baseNode.hashCode()); - result = prime * result + ((field == null) ? 0 : field.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof PathReference)) - return false; - PathReference other = (PathReference) obj; - if (baseNode == null) { - if (other.getBaseNode() != null) - return false; - } else if (!baseNode.equals(other.getBaseNode())) - return false; - if (field == null) { - if (other.getField() != null) - return false; - } else if (!field.equals(other.getField())) - return false; - return true; - } - -} +package com.blazebit.persistence.impl.expression; + + +public class SimplePathReference implements PathReference { + + private final Object baseNode; + private final String field; + + public SimplePathReference(Object baseNode, String field) { + this.baseNode = baseNode; + this.field = field; + } + + @Override + public Object getBaseNode() { + return baseNode; + } + + @Override + public String getField() { + return field; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((baseNode == null) ? 0 : baseNode.hashCode()); + result = prime * result + ((field == null) ? 0 : field.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof PathReference)) + return false; + PathReference other = (PathReference) obj; + if (baseNode == null) { + if (other.getBaseNode() != null) + return false; + } else if (!baseNode.equals(other.getBaseNode())) + return false; + if (field == null) { + if (other.getField() != null) + return false; + } else if (!field.equals(other.getField())) + return false; + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/Subquery.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/Subquery.java index 9fd0eb5ae5..86b34ca4f9 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/Subquery.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/Subquery.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.expression; - - -/** - * - * @author Christian Beikov - * @since 1.0 - */ -public interface Subquery { - - public String getQueryString(); - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.expression; + + +/** + * + * @author Christian Beikov + * @since 1.0 + */ +public interface Subquery { + + public String getQueryString(); + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SubqueryExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SubqueryExpression.java index a14b22138b..6691e1025f 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SubqueryExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SubqueryExpression.java @@ -1,72 +1,72 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class SubqueryExpression extends AbstractExpression { - - private final Subquery subquery; - - public SubqueryExpression(Subquery builder) { - this.subquery = builder; - } - - @Override - public SubqueryExpression clone() { - return new SubqueryExpression(subquery); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public Subquery getSubquery() { - return subquery; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 83 * hash + (this.subquery != null ? this.subquery.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final SubqueryExpression other = (SubqueryExpression) obj; - if (this.subquery != other.subquery && (this.subquery == null || !this.subquery.equals(other.subquery))) { - return false; - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class SubqueryExpression extends AbstractExpression { + + private final Subquery subquery; + + public SubqueryExpression(Subquery builder) { + this.subquery = builder; + } + + @Override + public SubqueryExpression clone() { + return new SubqueryExpression(subquery); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public Subquery getSubquery() { + return subquery; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 83 * hash + (this.subquery != null ? this.subquery.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final SubqueryExpression other = (SubqueryExpression) obj; + if (this.subquery != other.subquery && (this.subquery == null || !this.subquery.equals(other.subquery))) { + return false; + } + return true; + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SubqueryExpressionFactory.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SubqueryExpressionFactory.java index 6a831c6ef9..0674f94425 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SubqueryExpressionFactory.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SubqueryExpressionFactory.java @@ -1,94 +1,94 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -import java.util.Set; - -import com.blazebit.persistence.parser.JPQLSelectExpressionParser; - -import org.antlr.v4.runtime.ParserRuleContext; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class SubqueryExpressionFactory extends AbstractExpressionFactory { - - private final ExpressionFactory delegate; - - private final RuleInvoker simpleExpressionRuleInvoker = new RuleInvoker() { - - @Override - public ParserRuleContext invokeRule(JPQLSelectExpressionParser parser) { - return parser.parseSimpleSubqueryExpression(); - } - }; - - public SubqueryExpressionFactory(Set aggregateFunctions, ExpressionFactory delegate) { - super(aggregateFunctions); - this.delegate = delegate; - } - - @Override - public Expression createSimpleExpression(String expression) { - return super.createSimpleExpression(expression); - } - - @Override - protected RuleInvoker getSimpleExpressionRuleInvoker() { - return simpleExpressionRuleInvoker; - } - - // Delegates - - @Override - public PathExpression createPathExpression(String expression) { - return delegate.createPathExpression(expression); - } - - @Override - public Expression createCaseOperandExpression(String caseOperandExpression) { - return delegate.createCaseOperandExpression(caseOperandExpression); - } - - @Override - public Expression createScalarExpression(String expression) { - return delegate.createScalarExpression(expression); - } - - @Override - public Expression createArithmeticExpression(String expression) { - return delegate.createArithmeticExpression(expression); - } - - @Override - public Expression createStringExpression(String expression) { - return delegate.createStringExpression(expression); - } - - @Override - public Expression createOrderByExpression(String expression) { - return delegate.createOrderByExpression(expression); - } - - @Override - public Expression createInPredicateExpression(String[] parameterOrLiteralExpressions) { - return delegate.createInPredicateExpression(parameterOrLiteralExpressions); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +import java.util.Set; + +import com.blazebit.persistence.parser.JPQLSelectExpressionParser; + +import org.antlr.v4.runtime.ParserRuleContext; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class SubqueryExpressionFactory extends AbstractExpressionFactory { + + private final ExpressionFactory delegate; + + private final RuleInvoker simpleExpressionRuleInvoker = new RuleInvoker() { + + @Override + public ParserRuleContext invokeRule(JPQLSelectExpressionParser parser) { + return parser.parseSimpleSubqueryExpression(); + } + }; + + public SubqueryExpressionFactory(Set aggregateFunctions, ExpressionFactory delegate) { + super(aggregateFunctions); + this.delegate = delegate; + } + + @Override + public Expression createSimpleExpression(String expression) { + return super.createSimpleExpression(expression); + } + + @Override + protected RuleInvoker getSimpleExpressionRuleInvoker() { + return simpleExpressionRuleInvoker; + } + + // Delegates + + @Override + public PathExpression createPathExpression(String expression) { + return delegate.createPathExpression(expression); + } + + @Override + public Expression createCaseOperandExpression(String caseOperandExpression) { + return delegate.createCaseOperandExpression(caseOperandExpression); + } + + @Override + public Expression createScalarExpression(String expression) { + return delegate.createScalarExpression(expression); + } + + @Override + public Expression createArithmeticExpression(String expression) { + return delegate.createArithmeticExpression(expression); + } + + @Override + public Expression createStringExpression(String expression) { + return delegate.createStringExpression(expression); + } + + @Override + public Expression createOrderByExpression(String expression) { + return delegate.createOrderByExpression(expression); + } + + @Override + public Expression createInPredicateExpression(String[] parameterOrLiteralExpressions) { + return delegate.createInPredicateExpression(parameterOrLiteralExpressions); + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SyntaxErrorException.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SyntaxErrorException.java index e2ef47e354..e5bacc68e2 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SyntaxErrorException.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/SyntaxErrorException.java @@ -1,38 +1,38 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class SyntaxErrorException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public SyntaxErrorException() { - } - - public SyntaxErrorException(Throwable t) { - super(t); - } - - public SyntaxErrorException(String msg) { - super(msg); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class SyntaxErrorException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public SyntaxErrorException() { + } + + public SyntaxErrorException(Throwable t) { + super(t); + } + + public SyntaxErrorException(String msg) { + super(msg); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/WhenClauseExpression.java b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/WhenClauseExpression.java index 01629f7fe4..434265db60 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/expression/WhenClauseExpression.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/expression/WhenClauseExpression.java @@ -1,86 +1,86 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.expression; - -/** - * - * @author Moritz Becker - * @since 1.0 - */ -public class WhenClauseExpression extends AbstractExpression { - - private final Expression condition; - private Expression result; - - public WhenClauseExpression(Expression condition, Expression result) { - this.condition = condition; - this.result = result; - } - - @Override - public WhenClauseExpression clone() { - return new WhenClauseExpression(condition.clone(), result.clone()); - } - - public Expression getCondition() { - return condition; - } - - public Expression getResult() { - return result; - } - - public void setResult(Expression result) { - this.result = result; - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - @Override - public int hashCode() { - int hash = 5; - hash = 61 * hash + (this.condition != null ? this.condition.hashCode() : 0); - hash = 61 * hash + (this.result != null ? this.result.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final WhenClauseExpression other = (WhenClauseExpression) obj; - if (this.condition != other.condition && (this.condition == null || !this.condition.equals(other.condition))) { - return false; - } - if (this.result != other.result && (this.result == null || !this.result.equals(other.result))) { - return false; - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.expression; + +/** + * + * @author Moritz Becker + * @since 1.0 + */ +public class WhenClauseExpression extends AbstractExpression { + + private final Expression condition; + private Expression result; + + public WhenClauseExpression(Expression condition, Expression result) { + this.condition = condition; + this.result = result; + } + + @Override + public WhenClauseExpression clone() { + return new WhenClauseExpression(condition.clone(), result.clone()); + } + + public Expression getCondition() { + return condition; + } + + public Expression getResult() { + return result; + } + + public void setResult(Expression result) { + this.result = result; + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + @Override + public int hashCode() { + int hash = 5; + hash = 61 * hash + (this.condition != null ? this.condition.hashCode() : 0); + hash = 61 * hash + (this.result != null ? this.result.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final WhenClauseExpression other = (WhenClauseExpression) obj; + if (this.condition != other.condition && (this.condition == null || !this.condition.equals(other.condition))) { + return false; + } + if (this.result != other.result && (this.result == null || !this.result.equals(other.result))) { + return false; + } + return true; + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/BetweenPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/BetweenPredicate.java index 1cfc62f3c6..b5f202185b 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/BetweenPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/BetweenPredicate.java @@ -1,128 +1,128 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.AbstractExpression; -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class BetweenPredicate extends AbstractExpression implements Predicate, Negatable { - - private Expression left; - private Expression start; - private Expression end; - private boolean negated; - - public BetweenPredicate(Expression left, Expression start, Expression end) { - this(left, start, end, false); - } - - public BetweenPredicate(Expression left, Expression start, Expression end, boolean negated) { - this.negated = negated; - this.left = left; - this.start = start; - this.end = end; - } - - @Override - public BetweenPredicate clone() { - return new BetweenPredicate(left.clone(), start.clone(), end.clone(), negated); - } - - @Override - public boolean isNegated() { - return negated; - } - - @Override - public void setNegated(boolean negated) { - this.negated = negated; - } - - public Expression getLeft() { - return left; - } - - public Expression getStart() { - return start; - } - - public Expression getEnd() { - return end; - } - - public void setLeft(Expression left) { - this.left = left; - } - - public void setStart(Expression start) { - this.start = start; - } - - public void setEnd(Expression end) { - this.end = end; - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - @Override - public int hashCode() { - int hash = 7; - hash = 61 * hash + (this.left != null ? this.left.hashCode() : 0); - hash = 61 * hash + (this.start != null ? this.start.hashCode() : 0); - hash = 61 * hash + (this.end != null ? this.end.hashCode() : 0); - hash = 61 * hash + (this.negated ? 1 : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final BetweenPredicate other = (BetweenPredicate) obj; - if (this.left != other.left && (this.left == null || !this.left.equals(other.left))) { - return false; - } - if (this.start != other.start && (this.start == null || !this.start.equals(other.start))) { - return false; - } - if (this.end != other.end && (this.end == null || !this.end.equals(other.end))) { - return false; - } - if (this.negated != other.negated) { - return false; - } - return true; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.AbstractExpression; +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class BetweenPredicate extends AbstractExpression implements Predicate, Negatable { + + private Expression left; + private Expression start; + private Expression end; + private boolean negated; + + public BetweenPredicate(Expression left, Expression start, Expression end) { + this(left, start, end, false); + } + + public BetweenPredicate(Expression left, Expression start, Expression end, boolean negated) { + this.negated = negated; + this.left = left; + this.start = start; + this.end = end; + } + + @Override + public BetweenPredicate clone() { + return new BetweenPredicate(left.clone(), start.clone(), end.clone(), negated); + } + + @Override + public boolean isNegated() { + return negated; + } + + @Override + public void setNegated(boolean negated) { + this.negated = negated; + } + + public Expression getLeft() { + return left; + } + + public Expression getStart() { + return start; + } + + public Expression getEnd() { + return end; + } + + public void setLeft(Expression left) { + this.left = left; + } + + public void setStart(Expression start) { + this.start = start; + } + + public void setEnd(Expression end) { + this.end = end; + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 61 * hash + (this.left != null ? this.left.hashCode() : 0); + hash = 61 * hash + (this.start != null ? this.start.hashCode() : 0); + hash = 61 * hash + (this.end != null ? this.end.hashCode() : 0); + hash = 61 * hash + (this.negated ? 1 : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final BetweenPredicate other = (BetweenPredicate) obj; + if (this.left != other.left && (this.left == null || !this.left.equals(other.left))) { + return false; + } + if (this.start != other.start && (this.start == null || !this.start.equals(other.start))) { + return false; + } + if (this.end != other.end && (this.end == null || !this.end.equals(other.end))) { + return false; + } + if (this.negated != other.negated) { + return false; + } + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/BinaryExpressionPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/BinaryExpressionPredicate.java index c1200eeee5..29a2d07359 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/BinaryExpressionPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/BinaryExpressionPredicate.java @@ -1,81 +1,81 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.AbstractExpression; -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public abstract class BinaryExpressionPredicate extends AbstractExpression implements Predicate { - - protected Expression left; - protected Expression right; - - public BinaryExpressionPredicate(Expression left, Expression right) { - this.left = left; - this.right = right; - } - - @Override - public abstract BinaryExpressionPredicate clone(); - - public Expression getLeft() { - return left; - } - - public Expression getRight() { - return right; - } - - public void setLeft(Expression left) { - this.left = left; - } - - public void setRight(Expression right) { - this.right = right; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 17 * hash + (this.left != null ? this.left.hashCode() : 0); - hash = 17 * hash + (this.right != null ? this.right.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final BinaryExpressionPredicate other = (BinaryExpressionPredicate) obj; - if (this.left != other.left && (this.left == null || !this.left.equals(other.left))) { - return false; - } - if (this.right != other.right && (this.right == null || !this.right.equals(other.right))) { - return false; - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.AbstractExpression; +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public abstract class BinaryExpressionPredicate extends AbstractExpression implements Predicate { + + protected Expression left; + protected Expression right; + + public BinaryExpressionPredicate(Expression left, Expression right) { + this.left = left; + this.right = right; + } + + @Override + public abstract BinaryExpressionPredicate clone(); + + public Expression getLeft() { + return left; + } + + public Expression getRight() { + return right; + } + + public void setLeft(Expression left) { + this.left = left; + } + + public void setRight(Expression right) { + this.right = right; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 17 * hash + (this.left != null ? this.left.hashCode() : 0); + hash = 17 * hash + (this.right != null ? this.right.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final BinaryExpressionPredicate other = (BinaryExpressionPredicate) obj; + if (this.left != other.left && (this.left == null || !this.left.equals(other.left))) { + return false; + } + if (this.right != other.right && (this.right == null || !this.right.equals(other.right))) { + return false; + } + return true; + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/EqPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/EqPredicate.java index 9244330a11..218e037e71 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/EqPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/EqPredicate.java @@ -1,96 +1,96 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class EqPredicate extends QuantifiableBinaryExpressionPredicate implements Negatable { - - private boolean negated; - - public EqPredicate(boolean negated) { - this.negated = negated; - } - - public EqPredicate(Expression left, Expression right) { - this(left, right, PredicateQuantifier.ONE, false); - } - - public EqPredicate(Expression left, Expression right, boolean negated) { - super(left, right, PredicateQuantifier.ONE); - this.negated = negated; - } - - public EqPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - this(left, right, quantifier, false); - } - - public EqPredicate(Expression left, Expression right, PredicateQuantifier quantifier, boolean negated) { - super(left, right, quantifier); - this.negated = negated; - } - - @Override - public EqPredicate clone() { - return new EqPredicate(left.clone(), right.clone(), quantifier, negated); - } - - @Override - public boolean isNegated() { - return negated; - } - - @Override - public void setNegated(boolean negated) { - this.negated = negated; - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - @Override - public int hashCode() { - int hash = super.hashCode(); - hash = 97 * hash + (this.negated ? 1 : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (!super.equals(obj)) { - return false; - } - final EqPredicate other = (EqPredicate) obj; - if (this.negated != other.negated) { - return false; - } - return true; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class EqPredicate extends QuantifiableBinaryExpressionPredicate implements Negatable { + + private boolean negated; + + public EqPredicate(boolean negated) { + this.negated = negated; + } + + public EqPredicate(Expression left, Expression right) { + this(left, right, PredicateQuantifier.ONE, false); + } + + public EqPredicate(Expression left, Expression right, boolean negated) { + super(left, right, PredicateQuantifier.ONE); + this.negated = negated; + } + + public EqPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + this(left, right, quantifier, false); + } + + public EqPredicate(Expression left, Expression right, PredicateQuantifier quantifier, boolean negated) { + super(left, right, quantifier); + this.negated = negated; + } + + @Override + public EqPredicate clone() { + return new EqPredicate(left.clone(), right.clone(), quantifier, negated); + } + + @Override + public boolean isNegated() { + return negated; + } + + @Override + public void setNegated(boolean negated) { + this.negated = negated; + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 97 * hash + (this.negated ? 1 : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + final EqPredicate other = (EqPredicate) obj; + if (this.negated != other.negated) { + return false; + } + return true; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/ExistsPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/ExistsPredicate.java index f45c9cf847..122a4d9366 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/ExistsPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/ExistsPredicate.java @@ -1,55 +1,55 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class ExistsPredicate extends UnaryExpressionPredicate { - - public ExistsPredicate() { - super(null); - } - - public ExistsPredicate(boolean negated) { - super(null, negated); - } - - public ExistsPredicate(Expression expression, boolean negated) { - super(expression, negated); - } - - @Override - public ExistsPredicate clone() { - return new ExistsPredicate(expression.clone(), negated); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class ExistsPredicate extends UnaryExpressionPredicate { + + public ExistsPredicate() { + super(null); + } + + public ExistsPredicate(boolean negated) { + super(null, negated); + } + + public ExistsPredicate(Expression expression, boolean negated) { + super(expression, negated); + } + + @Override + public ExistsPredicate clone() { + return new ExistsPredicate(expression.clone(), negated); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/GePredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/GePredicate.java index 53f2ce4236..b8952c1b2a 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/GePredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/GePredicate.java @@ -1,53 +1,53 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class GePredicate extends QuantifiableBinaryExpressionPredicate { - - public GePredicate() { - } - - public GePredicate(Expression left, Expression right) { - super(left, right, PredicateQuantifier.ONE); - } - - public GePredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - super(left, right, quantifier); - } - - @Override - public GePredicate clone() { - return new GePredicate(left.clone(), right.clone(), quantifier); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class GePredicate extends QuantifiableBinaryExpressionPredicate { + + public GePredicate() { + } + + public GePredicate(Expression left, Expression right) { + super(left, right, PredicateQuantifier.ONE); + } + + public GePredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + super(left, right, quantifier); + } + + @Override + public GePredicate clone() { + return new GePredicate(left.clone(), right.clone(), quantifier); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/GtPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/GtPredicate.java index 3a9dad60c7..397dd41cd3 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/GtPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/GtPredicate.java @@ -1,53 +1,53 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class GtPredicate extends QuantifiableBinaryExpressionPredicate { - - public GtPredicate() { - } - - public GtPredicate(Expression left, Expression right) { - super(left, right, PredicateQuantifier.ONE); - } - - public GtPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - super(left, right, quantifier); - } - - @Override - public GtPredicate clone() { - return new GtPredicate(left.clone(), right.clone(), quantifier); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class GtPredicate extends QuantifiableBinaryExpressionPredicate { + + public GtPredicate() { + } + + public GtPredicate(Expression left, Expression right) { + super(left, right, PredicateQuantifier.ONE); + } + + public GtPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + super(left, right, quantifier); + } + + @Override + public GtPredicate clone() { + return new GtPredicate(left.clone(), right.clone(), quantifier); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/InPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/InPredicate.java index c0d9b9d54a..f86e47d317 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/InPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/InPredicate.java @@ -1,50 +1,50 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class InPredicate extends NegatableBinaryExpressionPredicate { - - public InPredicate(Expression left, Expression right, boolean negated) { - super(left, right, negated); - } - - public InPredicate(Expression left, Expression right) { - super(left, right); - } - - @Override - public InPredicate clone() { - return new InPredicate(left.clone(), right.clone(), negated); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class InPredicate extends NegatableBinaryExpressionPredicate { + + public InPredicate(Expression left, Expression right, boolean negated) { + super(left, right, negated); + } + + public InPredicate(Expression left, Expression right) { + super(left, right); + } + + @Override + public InPredicate clone() { + return new InPredicate(left.clone(), right.clone(), negated); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/IsEmptyPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/IsEmptyPredicate.java index 4c382ad0d6..464e637ec4 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/IsEmptyPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/IsEmptyPredicate.java @@ -1,51 +1,51 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class IsEmptyPredicate extends UnaryExpressionPredicate { - - public IsEmptyPredicate(Expression expression) { - super(expression); - } - - public IsEmptyPredicate(Expression expression, boolean negated) { - super(expression, negated); - } - - @Override - public IsEmptyPredicate clone() { - return new IsEmptyPredicate(expression.clone(), negated); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class IsEmptyPredicate extends UnaryExpressionPredicate { + + public IsEmptyPredicate(Expression expression) { + super(expression); + } + + public IsEmptyPredicate(Expression expression, boolean negated) { + super(expression, negated); + } + + @Override + public IsEmptyPredicate clone() { + return new IsEmptyPredicate(expression.clone(), negated); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/IsNullPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/IsNullPredicate.java index 12fe64d387..b9108ef885 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/IsNullPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/IsNullPredicate.java @@ -1,51 +1,51 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class IsNullPredicate extends UnaryExpressionPredicate { - - public IsNullPredicate(Expression expression) { - super(expression); - } - - public IsNullPredicate(Expression expression, boolean negated) { - super(expression, negated); - } - - @Override - public IsNullPredicate clone() { - return new IsNullPredicate(expression.clone(), negated); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class IsNullPredicate extends UnaryExpressionPredicate { + + public IsNullPredicate(Expression expression) { + super(expression); + } + + public IsNullPredicate(Expression expression, boolean negated) { + super(expression, negated); + } + + @Override + public IsNullPredicate clone() { + return new IsNullPredicate(expression.clone(), negated); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LePredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LePredicate.java index a22a95c48b..fdbd8622ec 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LePredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LePredicate.java @@ -1,53 +1,53 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class LePredicate extends QuantifiableBinaryExpressionPredicate { - - public LePredicate() { - } - - public LePredicate(Expression left, Expression right) { - super(left, right, PredicateQuantifier.ONE); - } - - public LePredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - super(left, right, quantifier); - } - - @Override - public LePredicate clone() { - return new LePredicate(left.clone(), right.clone(), quantifier); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class LePredicate extends QuantifiableBinaryExpressionPredicate { + + public LePredicate() { + } + + public LePredicate(Expression left, Expression right) { + super(left, right, PredicateQuantifier.ONE); + } + + public LePredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + super(left, right, quantifier); + } + + @Override + public LePredicate clone() { + return new LePredicate(left.clone(), right.clone(), quantifier); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LikePredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LikePredicate.java index 02baeeedd4..0b852e492a 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LikePredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LikePredicate.java @@ -1,93 +1,93 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class LikePredicate extends NegatableBinaryExpressionPredicate { - - private final boolean caseSensitive; - private final Character escapeCharacter; - - public LikePredicate(Expression left, Expression right, boolean caseSensitive, Character escapeCharacter) { - super(left, right); - this.caseSensitive = caseSensitive; - this.escapeCharacter = escapeCharacter; - } - - public LikePredicate(Expression left, Expression right, boolean caseSensitive, Character escapeCharacter, boolean negated) { - super(left, right, negated); - this.caseSensitive = caseSensitive; - this.escapeCharacter = escapeCharacter; - } - - @Override - public LikePredicate clone() { - return new LikePredicate(left.clone(), right.clone(), caseSensitive, escapeCharacter, negated); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - - public boolean isCaseSensitive() { - return caseSensitive; - } - - public Character getEscapeCharacter() { - return escapeCharacter; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 89 * hash + (this.caseSensitive ? 1 : 0); - hash = 89 * hash + (this.escapeCharacter != null ? this.escapeCharacter.hashCode() : 0); - hash = 89 * hash + super.hashCode(); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final LikePredicate other = (LikePredicate) obj; - if (this.caseSensitive != other.caseSensitive) { - return false; - } - if (this.escapeCharacter != other.escapeCharacter && (this.escapeCharacter == null || !this.escapeCharacter.equals(other.escapeCharacter))) { - return false; - } - return super.equals(obj); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class LikePredicate extends NegatableBinaryExpressionPredicate { + + private final boolean caseSensitive; + private final Character escapeCharacter; + + public LikePredicate(Expression left, Expression right, boolean caseSensitive, Character escapeCharacter) { + super(left, right); + this.caseSensitive = caseSensitive; + this.escapeCharacter = escapeCharacter; + } + + public LikePredicate(Expression left, Expression right, boolean caseSensitive, Character escapeCharacter, boolean negated) { + super(left, right, negated); + this.caseSensitive = caseSensitive; + this.escapeCharacter = escapeCharacter; + } + + @Override + public LikePredicate clone() { + return new LikePredicate(left.clone(), right.clone(), caseSensitive, escapeCharacter, negated); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + + public boolean isCaseSensitive() { + return caseSensitive; + } + + public Character getEscapeCharacter() { + return escapeCharacter; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 89 * hash + (this.caseSensitive ? 1 : 0); + hash = 89 * hash + (this.escapeCharacter != null ? this.escapeCharacter.hashCode() : 0); + hash = 89 * hash + super.hashCode(); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final LikePredicate other = (LikePredicate) obj; + if (this.caseSensitive != other.caseSensitive) { + return false; + } + if (this.escapeCharacter != other.escapeCharacter && (this.escapeCharacter == null || !this.escapeCharacter.equals(other.escapeCharacter))) { + return false; + } + return super.equals(obj); + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LtPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LtPredicate.java index e75d0c6bb3..6075789221 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LtPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/LtPredicate.java @@ -1,53 +1,53 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class LtPredicate extends QuantifiableBinaryExpressionPredicate { - - public LtPredicate() { - } - - public LtPredicate(Expression left, Expression right) { - super(left, right, PredicateQuantifier.ONE); - } - - public LtPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - super(left, right, quantifier); - } - - @Override - public LtPredicate clone() { - return new LtPredicate(left.clone(), right.clone(), quantifier); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class LtPredicate extends QuantifiableBinaryExpressionPredicate { + + public LtPredicate() { + } + + public LtPredicate(Expression left, Expression right) { + super(left, right, PredicateQuantifier.ONE); + } + + public LtPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + super(left, right, quantifier); + } + + @Override + public LtPredicate clone() { + return new LtPredicate(left.clone(), right.clone(), quantifier); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/MemberOfPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/MemberOfPredicate.java index 995356cead..8652e16d78 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/MemberOfPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/MemberOfPredicate.java @@ -1,51 +1,51 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public class MemberOfPredicate extends NegatableBinaryExpressionPredicate { - - public MemberOfPredicate(Expression left, Expression right) { - super(left, right); - } - - public MemberOfPredicate(Expression left, Expression right, boolean negated) { - super(left, right, negated); - } - - @Override - public MemberOfPredicate clone() { - return new MemberOfPredicate(left.clone(), right.clone(), negated); - } - - @Override - public void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public T accept(ResultVisitor visitor) { - return visitor.visit(this); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public class MemberOfPredicate extends NegatableBinaryExpressionPredicate { + + public MemberOfPredicate(Expression left, Expression right) { + super(left, right); + } + + public MemberOfPredicate(Expression left, Expression right, boolean negated) { + super(left, right, negated); + } + + @Override + public MemberOfPredicate clone() { + return new MemberOfPredicate(left.clone(), right.clone(), negated); + } + + @Override + public void accept(Visitor visitor) { + visitor.visit(this); + } + + @Override + public T accept(ResultVisitor visitor) { + return visitor.visit(this); + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/Negatable.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/Negatable.java index 5846c6d820..6931a8521e 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/Negatable.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/Negatable.java @@ -1,28 +1,28 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.predicate; - -/** - * - * @author Moritz Becker - */ -public interface Negatable { - - public boolean isNegated(); - - public void setNegated(boolean negated); -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.predicate; + +/** + * + * @author Moritz Becker + */ +public interface Negatable { + + public boolean isNegated(); + + public void setNegated(boolean negated); +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/NegatableBinaryExpressionPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/NegatableBinaryExpressionPredicate.java index c33f50e9f4..ebd76297da 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/NegatableBinaryExpressionPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/NegatableBinaryExpressionPredicate.java @@ -1,51 +1,51 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Moritz Becker - */ -public abstract class NegatableBinaryExpressionPredicate extends BinaryExpressionPredicate implements Negatable { - - protected boolean negated; - - public NegatableBinaryExpressionPredicate(Expression left, Expression right, boolean negated) { - super(left, right); - this.negated = negated; - } - - public NegatableBinaryExpressionPredicate(Expression left, Expression right) { - this(left, right, false); - } - - @Override - public abstract NegatableBinaryExpressionPredicate clone(); - - @Override - public boolean isNegated() { - return negated; - } - - @Override - public void setNegated(boolean negated) { - this.negated = negated; - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Moritz Becker + */ +public abstract class NegatableBinaryExpressionPredicate extends BinaryExpressionPredicate implements Negatable { + + protected boolean negated; + + public NegatableBinaryExpressionPredicate(Expression left, Expression right, boolean negated) { + super(left, right); + this.negated = negated; + } + + public NegatableBinaryExpressionPredicate(Expression left, Expression right) { + this(left, right, false); + } + + @Override + public abstract NegatableBinaryExpressionPredicate clone(); + + @Override + public boolean isNegated() { + return negated; + } + + @Override + public void setNegated(boolean negated) { + this.negated = negated; + } + +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/PredicateQuantifier.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/PredicateQuantifier.java index 75fead1d5d..827ff5fceb 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/PredicateQuantifier.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/PredicateQuantifier.java @@ -1,29 +1,29 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public enum PredicateQuantifier { - - ONE, - ALL, - ANY; -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public enum PredicateQuantifier { + + ONE, + ALL, + ANY; +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/QuantifiableBinaryExpressionPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/QuantifiableBinaryExpressionPredicate.java index 0c6475cc1b..d910bf064e 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/QuantifiableBinaryExpressionPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/QuantifiableBinaryExpressionPredicate.java @@ -1,77 +1,77 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public abstract class QuantifiableBinaryExpressionPredicate extends BinaryExpressionPredicate { - - protected PredicateQuantifier quantifier; - - public QuantifiableBinaryExpressionPredicate() { - this(null, null); - } - - public QuantifiableBinaryExpressionPredicate(Expression left, Expression right) { - this(left, right, PredicateQuantifier.ONE); - } - - public QuantifiableBinaryExpressionPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { - super(left, right); - this.quantifier = quantifier; - } - - @Override - public abstract QuantifiableBinaryExpressionPredicate clone(); - - public PredicateQuantifier getQuantifier() { - return quantifier; - } - - - public void setQuantifier(PredicateQuantifier quantifier) { - this.quantifier = quantifier; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 97 * hash + (this.quantifier != null ? this.quantifier.hashCode() : 0); - hash = 97 * hash + super.hashCode(); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final QuantifiableBinaryExpressionPredicate other = (QuantifiableBinaryExpressionPredicate) obj; - if (this.quantifier != other.quantifier) { - return false; - } - return super.equals(obj); - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public abstract class QuantifiableBinaryExpressionPredicate extends BinaryExpressionPredicate { + + protected PredicateQuantifier quantifier; + + public QuantifiableBinaryExpressionPredicate() { + this(null, null); + } + + public QuantifiableBinaryExpressionPredicate(Expression left, Expression right) { + this(left, right, PredicateQuantifier.ONE); + } + + public QuantifiableBinaryExpressionPredicate(Expression left, Expression right, PredicateQuantifier quantifier) { + super(left, right); + this.quantifier = quantifier; + } + + @Override + public abstract QuantifiableBinaryExpressionPredicate clone(); + + public PredicateQuantifier getQuantifier() { + return quantifier; + } + + + public void setQuantifier(PredicateQuantifier quantifier) { + this.quantifier = quantifier; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 97 * hash + (this.quantifier != null ? this.quantifier.hashCode() : 0); + hash = 97 * hash + super.hashCode(); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final QuantifiableBinaryExpressionPredicate other = (QuantifiableBinaryExpressionPredicate) obj; + if (this.quantifier != other.quantifier) { + return false; + } + return super.equals(obj); + } +} diff --git a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/UnaryExpressionPredicate.java b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/UnaryExpressionPredicate.java index 9d7d0241bb..d06ad4cd12 100644 --- a/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/UnaryExpressionPredicate.java +++ b/core/parser/src/main/java/com/blazebit/persistence/impl/predicate/UnaryExpressionPredicate.java @@ -1,83 +1,83 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.predicate; - -import com.blazebit.persistence.impl.expression.AbstractExpression; -import com.blazebit.persistence.impl.expression.Expression; - -/** - * - * @author Christian Beikov - * @author Moritz Becker - * @since 1.0 - */ -public abstract class UnaryExpressionPredicate extends AbstractExpression implements Predicate, Negatable { - - protected boolean negated; - protected Expression expression; - - public UnaryExpressionPredicate(Expression expression, boolean negated) { - this.expression = expression; - this.negated = negated; - } - - public UnaryExpressionPredicate(Expression expression) { - this(expression, false); - } - - @Override - public abstract UnaryExpressionPredicate clone(); - - public Expression getExpression() { - return expression; - } - - public void setExpression(Expression expression) { - this.expression = expression; - } - - @Override - public boolean isNegated() { - return negated; - } - - @Override - public void setNegated(boolean negated) { - this.negated = negated; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 29 * hash + (this.expression != null ? this.expression.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final UnaryExpressionPredicate other = (UnaryExpressionPredicate) obj; - if (this.expression != other.expression && (this.expression == null || !this.expression.equals(other.expression))) { - return false; - } - return true; - } -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.predicate; + +import com.blazebit.persistence.impl.expression.AbstractExpression; +import com.blazebit.persistence.impl.expression.Expression; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * @since 1.0 + */ +public abstract class UnaryExpressionPredicate extends AbstractExpression implements Predicate, Negatable { + + protected boolean negated; + protected Expression expression; + + public UnaryExpressionPredicate(Expression expression, boolean negated) { + this.expression = expression; + this.negated = negated; + } + + public UnaryExpressionPredicate(Expression expression) { + this(expression, false); + } + + @Override + public abstract UnaryExpressionPredicate clone(); + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + @Override + public boolean isNegated() { + return negated; + } + + @Override + public void setNegated(boolean negated) { + this.negated = negated; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 29 * hash + (this.expression != null ? this.expression.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final UnaryExpressionPredicate other = (UnaryExpressionPredicate) obj; + if (this.expression != other.expression && (this.expression == null || !this.expression.equals(other.expression))) { + return false; + } + return true; + } +} diff --git a/core/parser/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider b/core/parser/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider index a898e4643d..a379cab48f 100644 --- a/core/parser/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider +++ b/core/parser/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider @@ -1 +1 @@ -com.blazebit.persistence.impl.CriteriaBuilderConfigurationProviderImpl +com.blazebit.persistence.impl.CriteriaBuilderConfigurationProviderImpl diff --git a/core/parser/src/test/java/com/blazebit/persistence/impl/expression/AbstractTestExpressionFactory.java b/core/parser/src/test/java/com/blazebit/persistence/impl/expression/AbstractTestExpressionFactory.java index c5c3d84ff7..9e6007a990 100644 --- a/core/parser/src/test/java/com/blazebit/persistence/impl/expression/AbstractTestExpressionFactory.java +++ b/core/parser/src/test/java/com/blazebit/persistence/impl/expression/AbstractTestExpressionFactory.java @@ -1,54 +1,54 @@ -/* - * Copyright 2014 Blazebit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.blazebit.persistence.impl.expression; - -import java.util.Set; -import java.util.logging.Level; - -import org.antlr.v4.runtime.atn.PredictionMode; - -import com.blazebit.persistence.parser.JPQLSelectExpressionLexer; -import com.blazebit.persistence.parser.JPQLSelectExpressionParser; - -/** - * - * @author Moritz Becker - */ -public abstract class AbstractTestExpressionFactory extends AbstractExpressionFactory { - - - public AbstractTestExpressionFactory(Set aggregateFunctions) { - super(aggregateFunctions); - } - - @Override - protected void configureLexer(JPQLSelectExpressionLexer lexer) { - lexer.removeErrorListeners(); - lexer.addErrorListener(ERR_LISTENER); - } - - @Override - protected void configureParser(JPQLSelectExpressionParser parser) { - if (LOG.isLoggable(Level.FINEST)) { - parser.setTrace(true); - } - - parser.removeErrorListeners(); - parser.addErrorListener(ERR_LISTENER); - parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION); - } - -} +/* + * Copyright 2014 Blazebit. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.blazebit.persistence.impl.expression; + +import java.util.Set; +import java.util.logging.Level; + +import org.antlr.v4.runtime.atn.PredictionMode; + +import com.blazebit.persistence.parser.JPQLSelectExpressionLexer; +import com.blazebit.persistence.parser.JPQLSelectExpressionParser; + +/** + * + * @author Moritz Becker + */ +public abstract class AbstractTestExpressionFactory extends AbstractExpressionFactory { + + + public AbstractTestExpressionFactory(Set aggregateFunctions) { + super(aggregateFunctions); + } + + @Override + protected void configureLexer(JPQLSelectExpressionLexer lexer) { + lexer.removeErrorListeners(); + lexer.addErrorListener(ERR_LISTENER); + } + + @Override + protected void configureParser(JPQLSelectExpressionParser parser) { + if (LOG.isLoggable(Level.FINEST)) { + parser.setTrace(true); + } + + parser.removeErrorListeners(); + parser.addErrorListener(ERR_LISTENER); + parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION); + } + +} diff --git a/core/parser/src/test/java/com/blazebit/persistence/impl/expression/SetDelegate.java b/core/parser/src/test/java/com/blazebit/persistence/impl/expression/SetDelegate.java index 47415007b4..2b11f37264 100644 --- a/core/parser/src/test/java/com/blazebit/persistence/impl/expression/SetDelegate.java +++ b/core/parser/src/test/java/com/blazebit/persistence/impl/expression/SetDelegate.java @@ -1,63 +1,63 @@ -package com.blazebit.persistence.impl.expression; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Set; - -public abstract class SetDelegate implements Set { - - protected abstract Set getDelegate(); - - public int size() { - return getDelegate().size(); - } - - public boolean isEmpty() { - return getDelegate().isEmpty(); - } - - public boolean contains(Object o) { - return getDelegate().contains(o); - } - - public Iterator iterator() { - return getDelegate().iterator(); - } - - public Object[] toArray() { - return getDelegate().toArray(); - } - - public T[] toArray(T[] a) { - return getDelegate().toArray(a); - } - - public boolean add(E e) { - return getDelegate().add(e); - } - - public boolean remove(Object o) { - return getDelegate().remove(o); - } - - public boolean containsAll(Collection c) { - return getDelegate().containsAll(c); - } - - public boolean addAll(Collection c) { - return getDelegate().addAll(c); - } - - public boolean retainAll(Collection c) { - return getDelegate().retainAll(c); - } - - public boolean removeAll(Collection c) { - return getDelegate().removeAll(c); - } - - public void clear() { - getDelegate().clear(); - } - -} +package com.blazebit.persistence.impl.expression; + +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; + +public abstract class SetDelegate implements Set { + + protected abstract Set getDelegate(); + + public int size() { + return getDelegate().size(); + } + + public boolean isEmpty() { + return getDelegate().isEmpty(); + } + + public boolean contains(Object o) { + return getDelegate().contains(o); + } + + public Iterator iterator() { + return getDelegate().iterator(); + } + + public Object[] toArray() { + return getDelegate().toArray(); + } + + public T[] toArray(T[] a) { + return getDelegate().toArray(a); + } + + public boolean add(E e) { + return getDelegate().add(e); + } + + public boolean remove(Object o) { + return getDelegate().remove(o); + } + + public boolean containsAll(Collection c) { + return getDelegate().containsAll(c); + } + + public boolean addAll(Collection c) { + return getDelegate().addAll(c); + } + + public boolean retainAll(Collection c) { + return getDelegate().retainAll(c); + } + + public boolean removeAll(Collection c) { + return getDelegate().removeAll(c); + } + + public void clear() { + getDelegate().clear(); + } + +} diff --git a/core/parser/src/test/resources/logging.properties b/core/parser/src/test/resources/logging.properties index 1f37c793d7..2026606227 100644 --- a/core/parser/src/test/resources/logging.properties +++ b/core/parser/src/test/resources/logging.properties @@ -1,23 +1,23 @@ -# Copyright 2014 Blazebit. -# -# 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. - -handlers = java.util.logging.ConsoleHandler - -# For debugging purposes use ALL -# We turn it off for TravisCI build with OFF -#com.blazebit.persistence.parser.level = ALL -com.blazebit.persistence.parser.level = OFF - -java.util.logging.ConsoleHandler.level = ALL +# Copyright 2014 Blazebit. +# +# 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. + +handlers = java.util.logging.ConsoleHandler + +# For debugging purposes use ALL +# We turn it off for TravisCI build with OFF +#com.blazebit.persistence.parser.level = ALL +com.blazebit.persistence.parser.level = OFF + +java.util.logging.ConsoleHandler.level = ALL java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter \ No newline at end of file diff --git a/core/testsuite/log4j.properties b/core/testsuite/log4j.properties index bbb6885ea4..002c9bff07 100644 --- a/core/testsuite/log4j.properties +++ b/core/testsuite/log4j.properties @@ -1,20 +1,20 @@ -# Copyright 2014 Blazebit. -# -# 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. - -# Define the destination and format of our logging -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n - +# Copyright 2014 Blazebit. +# +# 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. + +# Define the destination and format of our logging +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n + #log4j.category.DataNucleus.Enhancer=DEBUG, A1 \ No newline at end of file diff --git a/core/testsuite/src/test/resources/logging.properties b/core/testsuite/src/test/resources/logging.properties index 8490c6e5f6..f715231889 100644 --- a/core/testsuite/src/test/resources/logging.properties +++ b/core/testsuite/src/test/resources/logging.properties @@ -1,29 +1,29 @@ -# Copyright 2014 Blazebit. -# -# 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. - -handlers = java.util.logging.ConsoleHandler - -# For debugging purposes use ALL -# We turn it off for TravisCI build with SEVERE -org.hibernate.level = SEVERE -org.hibernate.tool.hbm2ddl.level = OFF -#org.hibernate.SQL.level = ALL -#org.hibernate.type.descriptor.sql.level = ALL -#org.hibernate.tool.hbm2ddl.level = ALL -#org.hibernate.pretty.level = ALL -#org.hibernate.cache.level = ALL -#org.hibernate.hql.internal.ast.AST.level = ALL - -java.util.logging.ConsoleHandler.level = ALL +# Copyright 2014 Blazebit. +# +# 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. + +handlers = java.util.logging.ConsoleHandler + +# For debugging purposes use ALL +# We turn it off for TravisCI build with SEVERE +org.hibernate.level = SEVERE +org.hibernate.tool.hbm2ddl.level = OFF +#org.hibernate.SQL.level = ALL +#org.hibernate.type.descriptor.sql.level = ALL +#org.hibernate.tool.hbm2ddl.level = ALL +#org.hibernate.pretty.level = ALL +#org.hibernate.cache.level = ALL +#org.hibernate.hql.internal.ast.AST.level = ALL + +java.util.logging.ConsoleHandler.level = ALL java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter \ No newline at end of file diff --git a/documentation/src/main/asciidoc/core/manual/en_US/05_predicate_builder.adoc b/documentation/src/main/asciidoc/core/manual/en_US/05_predicate_builder.adoc index a303570527..8e28ca216d 100644 --- a/documentation/src/main/asciidoc/core/manual/en_US/05_predicate_builder.adoc +++ b/documentation/src/main/asciidoc/core/manual/en_US/05_predicate_builder.adoc @@ -1,4 +1,4 @@ -== Predicate Builder - -TODO: For every possible predicate, write some text and give examples + +== Predicate Builder + +TODO: For every possible predicate, write some text and give examples + TODO: Describe how predicates are built with chained method calls + \ No newline at end of file diff --git a/documentation/src/main/asciidoc/core/manual/en_US/06_where_clause.adoc b/documentation/src/main/asciidoc/core/manual/en_US/06_where_clause.adoc index 1b0cec467b..df19039d8d 100644 --- a/documentation/src/main/asciidoc/core/manual/en_US/06_where_clause.adoc +++ b/documentation/src/main/asciidoc/core/manual/en_US/06_where_clause.adoc @@ -1,4 +1,4 @@ -== Where clause - -TODO: Describe the features here with examples + +== Where clause + +TODO: Describe the features here with examples + TODO: Mainly refer to the predicate building section which should explain the basics + \ No newline at end of file diff --git a/documentation/src/main/asciidoc/core/manual/en_US/07_group_by_having_clause.adoc b/documentation/src/main/asciidoc/core/manual/en_US/07_group_by_having_clause.adoc index d0e9fb20ac..b59cddf7dd 100644 --- a/documentation/src/main/asciidoc/core/manual/en_US/07_group_by_having_clause.adoc +++ b/documentation/src/main/asciidoc/core/manual/en_US/07_group_by_having_clause.adoc @@ -1,8 +1,8 @@ -== Group by and having clause - -TODO: Describe the features here with examples + -TODO: Mainly refer to the predicate building section which should explain the basics + -TODO: Info that group by and having is not possible on paginated criteria builders + -TODO: Note that group by subquery is not possible -TODO: Note that there is a non compliant mode which is enabled by default that allows expressions in the group by +== Group by and having clause + +TODO: Describe the features here with examples + +TODO: Mainly refer to the predicate building section which should explain the basics + +TODO: Info that group by and having is not possible on paginated criteria builders + +TODO: Note that group by subquery is not possible +TODO: Note that there is a non compliant mode which is enabled by default that allows expressions in the group by TODO: Note that OpenJPA does not support anything but paths and simple function expressions, all other providers support arbitrary expressions \ No newline at end of file diff --git a/documentation/src/main/asciidoc/core/manual/en_US/08_order_by_clause.adoc b/documentation/src/main/asciidoc/core/manual/en_US/08_order_by_clause.adoc index 410826ed85..56b0546016 100644 --- a/documentation/src/main/asciidoc/core/manual/en_US/08_order_by_clause.adoc +++ b/documentation/src/main/asciidoc/core/manual/en_US/08_order_by_clause.adoc @@ -1,6 +1,6 @@ -== Order by clause - -TODO: Describe the features here with examples + -TODO: Mention that arbitrary expression can be used + -TODO: Mention the default setting for null precedence and explain that this is necessary to have portable code + +== Order by clause + +TODO: Describe the features here with examples + +TODO: Mention that arbitrary expression can be used + +TODO: Mention the default setting for null precedence and explain that this is necessary to have portable code + TODO: Info that subqueries can only be ordered by, by using a select alias in the order by + \ No newline at end of file diff --git a/documentation/src/main/asciidoc/core/manual/en_US/09_select_clause.adoc b/documentation/src/main/asciidoc/core/manual/en_US/09_select_clause.adoc index 06f14efc59..bd2d56d678 100644 --- a/documentation/src/main/asciidoc/core/manual/en_US/09_select_clause.adoc +++ b/documentation/src/main/asciidoc/core/manual/en_US/09_select_clause.adoc @@ -1,40 +1,40 @@ -== Select clause - -TODO: Describe the features here with examples -TODO: Mention that arbitrary expression can be used - -=== Tuple select - -TODO: Mention that by default JPA creates `Object[]` but you can also use a `javax.persistence.Tuple` - -=== Case expressions - -TODO: Explain that you can use case when in string expression and that there is also the API - -==== Typesafe - -TODO: Mention API - -==== Expression support - -TODO: Mention that case when expressions can be used in expressions - -==== Searched case expression (simple case) - -==== Conditional case expression - -=== Subqueries - -TODO: Mention that subqueries don't have to be repeated if used in select, because select alias can be used. - -==== Wrapping expression - -TODO: Explain how selectSubquery(String subqueryAlias, String expression) works - -=== Select new support - -TODO: Mention the select new methods and explain what they do - -=== Object builder - +== Select clause + +TODO: Describe the features here with examples +TODO: Mention that arbitrary expression can be used + +=== Tuple select + +TODO: Mention that by default JPA creates `Object[]` but you can also use a `javax.persistence.Tuple` + +=== Case expressions + +TODO: Explain that you can use case when in string expression and that there is also the API + +==== Typesafe + +TODO: Mention API + +==== Expression support + +TODO: Mention that case when expressions can be used in expressions + +==== Searched case expression (simple case) + +==== Conditional case expression + +=== Subqueries + +TODO: Mention that subqueries don't have to be repeated if used in select, because select alias can be used. + +==== Wrapping expression + +TODO: Explain how selectSubquery(String subqueryAlias, String expression) works + +=== Select new support + +TODO: Mention the select new methods and explain what they do + +=== Object builder + TODO: Mention that entity views use this extension point \ No newline at end of file diff --git a/documentation/src/main/asciidoc/core/manual/en_US/10_pagination.adoc b/documentation/src/main/asciidoc/core/manual/en_US/10_pagination.adoc index dc3b91bc48..2abaab6011 100644 --- a/documentation/src/main/asciidoc/core/manual/en_US/10_pagination.adoc +++ b/documentation/src/main/asciidoc/core/manual/en_US/10_pagination.adoc @@ -1,19 +1,19 @@ -== Pagination - -TODO: Describe the features here with examples - -=== General - -TODO: Write a section about how pagination support is implemented. - -=== Limitations - -TODO: Describe the limitations already mentioned in the javadoc and if one needs better control then he should work on the TypedQuery directly - -=== Offset pagination - -TODO: Describe performance penalty and suggest that keyset pagination is better - -=== Keyset pagination - +== Pagination + +TODO: Describe the features here with examples + +=== General + +TODO: Write a section about how pagination support is implemented. + +=== Limitations + +TODO: Describe the limitations already mentioned in the javadoc and if one needs better control then he should work on the TypedQuery directly + +=== Offset pagination + +TODO: Describe performance penalty and suggest that keyset pagination is better + +=== Keyset pagination + TODO: Describe that a unique index column is needed \ No newline at end of file diff --git a/documentation/src/main/style/css/style.css b/documentation/src/main/style/css/style.css index 9f9861ac5c..7072b777a4 100644 --- a/documentation/src/main/style/css/style.css +++ b/documentation/src/main/style/css/style.css @@ -1,406 +1,406 @@ - -/* - * AsciiDoc theme based on css from http://volnitsky.com, - * which was in turn based on default theme from AsciiDoc - */ - -.vendor { - background: url("../images/vendor.png") no-repeat scroll left top rgba(0, 0, 0, 0); - display: block; - float: left; - height: 29px; - width: 104px; -} - -.vendor strong { - display: none; -} - -.logo { - background: url("../images/logo.png") no-repeat scroll left top rgba(0, 0, 0, 0); - display: block; - float: left; - height: 29px; - width: 170px; - float: right; -} - -.logo strong { - display: none; -} - -a { - color: blue; - text-decoration: underline; -} -a:visited { - color: fuchsia; -} - -em { - font-style: italic; - color: #444466; -} - -strong { - font-weight: bold; - color: #444466; -} - -h1, h2, h3, h4, h5, h6 { - color: #666688; - font-family: sans-serif; - /*margin-top: 1.2em;*/ - margin-bottom: 0.5em; - line-height: 1.3; -} - -h1, h2, h3 { border-bottom: 2px solid #666688; } -h2 { padding-top: 0.5em; } -h3 { float: left; } -h3 + * { clear: left; } - -div.sectionbody { - /*font-family: serif;*/ - margin-left: 0; -} - -hr { - border: 1px solid #444466; -} - -p { - margin-top: 0.5em; - margin-bottom: 0.5em; -} - -ul, ol, li > p { - margin-top: 0; -} - -pre { - padding: 0; - margin: 0; -} - -span.author { - color: #444466; - font-family: sans-serif; - font-weight: bold; - font-size: 1.1em; -} -span.email {} -span#revnumber, span#revdate, span#revremark { font-family: sans-serif; } - -div#footer { - font-family: sans-serif; - font-size: small; - border-top: 2px solid silver; - padding-top: 0.5em; - margin-top: 4.0em; -} - -div#footer-text { - float: left; - padding-bottom: 0.5em; -} - -div#footer-badges { - float: right; - padding-bottom: 0.5em; -} - -div#preamble { - margin-top: 1.5em; - margin-bottom: 1.5em; -} - -div.tableblock, div.imageblock, div.exampleblock, div.verseblock, -div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, -div.admonitionblock { - margin-top: 1.5em; - margin-bottom: 1.5em; -} - -div.admonitionblock { - margin-top: 2.5em; - margin-bottom: 2.5em; -} - -div.content { /* Block element content. */ - padding: 0; -} - -/* Block element titles. */ -div.title, caption.title { - color: #444466; - font-family: sans-serif; - font-weight: bold; - text-align: left; - margin-top: 1.0em; - margin-bottom: 0.5em; -} -div.title + * { - margin-top: 0; -} - -td div.title:first-child { - margin-top: 0.0em; -} -div.content div.title:first-child { - margin-top: 0.0em; -} -div.content + div.title { - margin-top: 0.0em; -} - -div.sidebarblock > div.content { - background: #ffffee; - border: 1px solid silver; - padding: 0.5em; -} - -div.listingblock > div.content { - border: 1px solid silver; - background: #f4f4f4; - padding: 0.5em; -} - -div.quoteblock { - padding-left: 2.0em; - margin-right: 10%; -} -div.quoteblock > div.attribution { - padding-top: 0.5em; - text-align: right; -} - -div.verseblock { - padding-left: 2.0em; - margin-right: 10%; -} -div.verseblock > pre.content { - font-family: inherit; -} -div.verseblock > div.attribution { - padding-top: 0.75em; - text-align: left; -} -/* DEPRECATED: Pre version 8.2.7 verse style literal block. */ -div.verseblock + div.attribution { - text-align: left; -} - -div.admonitionblock .icon { - vertical-align: top; - font-size: 1.1em; - font-weight: bold; - text-decoration: underline; - color: #444466; - padding-right: 0.5em; -} -div.admonitionblock td.content { - padding-left: 0.5em; - border-left: 2px solid silver; -} - -div.exampleblock > div.content { - border-left: 2px solid silver; - padding: 0.5em; -} - -div.imageblock div.content { padding-left: 0; } -span.image img { border-style: none; } -a.image:visited { color: white; } - -dl { - margin-top: 0.8em; - margin-bottom: 0.8em; -} -dt { - margin-top: 0.5em; - margin-bottom: 0; - font-style: normal; - color: #444466; -} -dd > *:first-child { - margin-top: 0.1em; -} - -ul, ol { - list-style-position: outside; -} -ol.arabic { - list-style-type: decimal; -} -ol.loweralpha { - list-style-type: lower-alpha; -} -ol.upperalpha { - list-style-type: upper-alpha; -} -ol.lowerroman { - list-style-type: lower-roman; -} -ol.upperroman { - list-style-type: upper-roman; -} - -div.compact ul, div.compact ol, -div.compact p, div.compact p, -div.compact div, div.compact div { - margin-top: 0.1em; - margin-bottom: 0.1em; -} - -div.tableblock > table { - border: 3px solid #444466; -} -thead { - font-family: sans-serif; - font-weight: bold; - color: #444466; -} -tfoot { - font-weight: bold; -} -td > div.verse { - white-space: pre; -} -p.table { - margin-top: 0; -} -/* Because the table frame attribute is overriden by CSS in most browsers. */ -div.tableblock > table[frame="void"] { - border-style: none; -} -div.tableblock > table[frame="hsides"] { - border-left-style: none; - border-right-style: none; -} -div.tableblock > table[frame="vsides"] { - border-top-style: none; - border-bottom-style: none; -} - - -div.hdlist { - margin-top: 0.8em; - margin-bottom: 0.8em; -} -div.hdlist tr { - padding-bottom: 15px; -} -dt.hdlist1.strong, td.hdlist1.strong { - font-weight: bold; -} -td.hdlist1 { - vertical-align: top; - font-style: normal; - padding-right: 0.8em; - color: #444466; -} -td.hdlist2 { - vertical-align: top; -} -div.hdlist.compact tr { - margin: 0; - padding-bottom: 0; -} - -.comment { - background: yellow; -} - -@media print { - div#footer-badges { display: none; } -} - -div#toctitle { - color: #6644bb; - font-family: sans-serif; - font-size: 1.1em; - font-weight: bold; - margin-top: 1.0em; - margin-bottom: 0.1em; -} - -div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { - margin-top: 0; - margin-bottom: 0; -} -div.toclevel2 { - margin-left: 2em; - font-size: 0.9em; -} -div.toclevel3 { - margin-left: 4em; - font-size: 0.9em; -} -div.toclevel4 { - margin-left: 6em; - font-size: 0.9em; -} -body { - font-family: "Cambria", "URW Bookman L", "Georgia", "Arial", sans-serif; - max-width: 55em; - padding-left: 5%; - -} - -tt, div.listingblock > div.content { - font-family: "Consolas", "Andale Mono", "Courier New", monospace; - color: #004400; - background: #f4f4f4; - max-width: 80em; - line-height: 1.2em; -} - -.paragraph p { - line-height: 1.5em; - margin-top: 1em; -} - -.paragraph p, li, dd, .content { max-width: 45em; } -.admonitionblock { max-width: 35em; } - -div.sectionbody > div.ulist > ul > li { - list-style-type: square; - /*font-size: 200%; */ - color: #aaa; -} - div.sectionbody > div.ulist > ul > li > * { - color: black; - /*font-size: 50%;*/ - } - - -div.sectionbody > div.ulist > ul > li > div.ulist > ul > li { - color: #ccd ; - /*list-style-type: circle ;*/ -} - div.sectionbody > div.ulist > ul > li > div.ulist > ul > li > * { - color: black ; - } - -h1, h2, h3, h4, h5, h6 { - font-family: "Candara", "Arial", sans-serif; - letter-spacing:+0.15em; -} - -h1, h2, h3 { border-bottom: 2px solid #ccd; } - -em { - font-style: normal ! important; - font-weight: bold ! important; - color: #662222 ! important; - letter-spacing:+0.08em ! important; -} - -a { - text-decoration: none !important; -} - -a:hover, a:focus { - text-decoration: underline !important; -} + +/* + * AsciiDoc theme based on css from http://volnitsky.com, + * which was in turn based on default theme from AsciiDoc + */ + +.vendor { + background: url("../images/vendor.png") no-repeat scroll left top rgba(0, 0, 0, 0); + display: block; + float: left; + height: 29px; + width: 104px; +} + +.vendor strong { + display: none; +} + +.logo { + background: url("../images/logo.png") no-repeat scroll left top rgba(0, 0, 0, 0); + display: block; + float: left; + height: 29px; + width: 170px; + float: right; +} + +.logo strong { + display: none; +} + +a { + color: blue; + text-decoration: underline; +} +a:visited { + color: fuchsia; +} + +em { + font-style: italic; + color: #444466; +} + +strong { + font-weight: bold; + color: #444466; +} + +h1, h2, h3, h4, h5, h6 { + color: #666688; + font-family: sans-serif; + /*margin-top: 1.2em;*/ + margin-bottom: 0.5em; + line-height: 1.3; +} + +h1, h2, h3 { border-bottom: 2px solid #666688; } +h2 { padding-top: 0.5em; } +h3 { float: left; } +h3 + * { clear: left; } + +div.sectionbody { + /*font-family: serif;*/ + margin-left: 0; +} + +hr { + border: 1px solid #444466; +} + +p { + margin-top: 0.5em; + margin-bottom: 0.5em; +} + +ul, ol, li > p { + margin-top: 0; +} + +pre { + padding: 0; + margin: 0; +} + +span.author { + color: #444466; + font-family: sans-serif; + font-weight: bold; + font-size: 1.1em; +} +span.email {} +span#revnumber, span#revdate, span#revremark { font-family: sans-serif; } + +div#footer { + font-family: sans-serif; + font-size: small; + border-top: 2px solid silver; + padding-top: 0.5em; + margin-top: 4.0em; +} + +div#footer-text { + float: left; + padding-bottom: 0.5em; +} + +div#footer-badges { + float: right; + padding-bottom: 0.5em; +} + +div#preamble { + margin-top: 1.5em; + margin-bottom: 1.5em; +} + +div.tableblock, div.imageblock, div.exampleblock, div.verseblock, +div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, +div.admonitionblock { + margin-top: 1.5em; + margin-bottom: 1.5em; +} + +div.admonitionblock { + margin-top: 2.5em; + margin-bottom: 2.5em; +} + +div.content { /* Block element content. */ + padding: 0; +} + +/* Block element titles. */ +div.title, caption.title { + color: #444466; + font-family: sans-serif; + font-weight: bold; + text-align: left; + margin-top: 1.0em; + margin-bottom: 0.5em; +} +div.title + * { + margin-top: 0; +} + +td div.title:first-child { + margin-top: 0.0em; +} +div.content div.title:first-child { + margin-top: 0.0em; +} +div.content + div.title { + margin-top: 0.0em; +} + +div.sidebarblock > div.content { + background: #ffffee; + border: 1px solid silver; + padding: 0.5em; +} + +div.listingblock > div.content { + border: 1px solid silver; + background: #f4f4f4; + padding: 0.5em; +} + +div.quoteblock { + padding-left: 2.0em; + margin-right: 10%; +} +div.quoteblock > div.attribution { + padding-top: 0.5em; + text-align: right; +} + +div.verseblock { + padding-left: 2.0em; + margin-right: 10%; +} +div.verseblock > pre.content { + font-family: inherit; +} +div.verseblock > div.attribution { + padding-top: 0.75em; + text-align: left; +} +/* DEPRECATED: Pre version 8.2.7 verse style literal block. */ +div.verseblock + div.attribution { + text-align: left; +} + +div.admonitionblock .icon { + vertical-align: top; + font-size: 1.1em; + font-weight: bold; + text-decoration: underline; + color: #444466; + padding-right: 0.5em; +} +div.admonitionblock td.content { + padding-left: 0.5em; + border-left: 2px solid silver; +} + +div.exampleblock > div.content { + border-left: 2px solid silver; + padding: 0.5em; +} + +div.imageblock div.content { padding-left: 0; } +span.image img { border-style: none; } +a.image:visited { color: white; } + +dl { + margin-top: 0.8em; + margin-bottom: 0.8em; +} +dt { + margin-top: 0.5em; + margin-bottom: 0; + font-style: normal; + color: #444466; +} +dd > *:first-child { + margin-top: 0.1em; +} + +ul, ol { + list-style-position: outside; +} +ol.arabic { + list-style-type: decimal; +} +ol.loweralpha { + list-style-type: lower-alpha; +} +ol.upperalpha { + list-style-type: upper-alpha; +} +ol.lowerroman { + list-style-type: lower-roman; +} +ol.upperroman { + list-style-type: upper-roman; +} + +div.compact ul, div.compact ol, +div.compact p, div.compact p, +div.compact div, div.compact div { + margin-top: 0.1em; + margin-bottom: 0.1em; +} + +div.tableblock > table { + border: 3px solid #444466; +} +thead { + font-family: sans-serif; + font-weight: bold; + color: #444466; +} +tfoot { + font-weight: bold; +} +td > div.verse { + white-space: pre; +} +p.table { + margin-top: 0; +} +/* Because the table frame attribute is overriden by CSS in most browsers. */ +div.tableblock > table[frame="void"] { + border-style: none; +} +div.tableblock > table[frame="hsides"] { + border-left-style: none; + border-right-style: none; +} +div.tableblock > table[frame="vsides"] { + border-top-style: none; + border-bottom-style: none; +} + + +div.hdlist { + margin-top: 0.8em; + margin-bottom: 0.8em; +} +div.hdlist tr { + padding-bottom: 15px; +} +dt.hdlist1.strong, td.hdlist1.strong { + font-weight: bold; +} +td.hdlist1 { + vertical-align: top; + font-style: normal; + padding-right: 0.8em; + color: #444466; +} +td.hdlist2 { + vertical-align: top; +} +div.hdlist.compact tr { + margin: 0; + padding-bottom: 0; +} + +.comment { + background: yellow; +} + +@media print { + div#footer-badges { display: none; } +} + +div#toctitle { + color: #6644bb; + font-family: sans-serif; + font-size: 1.1em; + font-weight: bold; + margin-top: 1.0em; + margin-bottom: 0.1em; +} + +div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { + margin-top: 0; + margin-bottom: 0; +} +div.toclevel2 { + margin-left: 2em; + font-size: 0.9em; +} +div.toclevel3 { + margin-left: 4em; + font-size: 0.9em; +} +div.toclevel4 { + margin-left: 6em; + font-size: 0.9em; +} +body { + font-family: "Cambria", "URW Bookman L", "Georgia", "Arial", sans-serif; + max-width: 55em; + padding-left: 5%; + +} + +tt, div.listingblock > div.content { + font-family: "Consolas", "Andale Mono", "Courier New", monospace; + color: #004400; + background: #f4f4f4; + max-width: 80em; + line-height: 1.2em; +} + +.paragraph p { + line-height: 1.5em; + margin-top: 1em; +} + +.paragraph p, li, dd, .content { max-width: 45em; } +.admonitionblock { max-width: 35em; } + +div.sectionbody > div.ulist > ul > li { + list-style-type: square; + /*font-size: 200%; */ + color: #aaa; +} + div.sectionbody > div.ulist > ul > li > * { + color: black; + /*font-size: 50%;*/ + } + + +div.sectionbody > div.ulist > ul > li > div.ulist > ul > li { + color: #ccd ; + /*list-style-type: circle ;*/ +} + div.sectionbody > div.ulist > ul > li > div.ulist > ul > li > * { + color: black ; + } + +h1, h2, h3, h4, h5, h6 { + font-family: "Candara", "Arial", sans-serif; + letter-spacing:+0.15em; +} + +h1, h2, h3 { border-bottom: 2px solid #ccd; } + +em { + font-style: normal ! important; + font-weight: bold ! important; + color: #662222 ! important; + letter-spacing:+0.08em ! important; +} + +a { + text-decoration: none !important; +} + +a:hover, a:focus { + text-decoration: underline !important; +} diff --git a/documentation/src/main/style/images/icons/README b/documentation/src/main/style/images/icons/README index 4ca2821a26..f12b2a730c 100644 --- a/documentation/src/main/style/images/icons/README +++ b/documentation/src/main/style/images/icons/README @@ -1,5 +1,5 @@ -Replaced the plain DocBook XSL admonition icons with Jimmac's DocBook -icons (http://jimmac.musichall.cz/ikony.php3). I dropped transparency -from the Jimmac icons to get round MS IE and FOP PNG incompatibilies. - -Stuart Rackham +Replaced the plain DocBook XSL admonition icons with Jimmac's DocBook +icons (http://jimmac.musichall.cz/ikony.php3). I dropped transparency +from the Jimmac icons to get round MS IE and FOP PNG incompatibilies. + +Stuart Rackham