http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/InPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/InPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/InPredicateImpl.java new file mode 100644 index 0000000..159c1a2 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/InPredicateImpl.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import java.util.List; +import org.apache.polygene.library.sql.generator.grammar.booleans.InPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class InPredicateImpl extends MultiPredicateImpl<InPredicate> + implements InPredicate +{ + + public InPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, + List<NonBooleanExpression> rights ) + { + this( processor, InPredicate.class, left, rights ); + } + + protected InPredicateImpl( SQLProcessorAggregator processor, Class<? extends InPredicate> predicateClass, + NonBooleanExpression left, List<NonBooleanExpression> rights ) + { + super( processor, predicateClass, left, rights ); + } + + public InPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, NonBooleanExpression... rights ) + { + this( processor, InPredicate.class, left, rights ); + } + + protected InPredicateImpl( SQLProcessorAggregator processor, Class<? extends InPredicate> predicateClass, + NonBooleanExpression left, NonBooleanExpression... rights ) + { + super( processor, predicateClass, left, rights ); + } +}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/IsNotNullPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/IsNotNullPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/IsNotNullPredicateImpl.java new file mode 100644 index 0000000..eff8be0 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/IsNotNullPredicateImpl.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.IsNotNullPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class IsNotNullPredicateImpl extends UnaryPredicateImpl<IsNotNullPredicate> + implements IsNotNullPredicate +{ + + public IsNotNullPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression expression ) + { + this( processor, IsNotNullPredicate.class, expression ); + } + + protected IsNotNullPredicateImpl( SQLProcessorAggregator processor, + Class<? extends IsNotNullPredicate> predicateClass, NonBooleanExpression expression ) + { + super( processor, predicateClass, expression ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/IsNullPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/IsNullPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/IsNullPredicateImpl.java new file mode 100644 index 0000000..4dec363 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/IsNullPredicateImpl.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.IsNullPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class IsNullPredicateImpl extends UnaryPredicateImpl<IsNullPredicate> + implements IsNullPredicate +{ + + public IsNullPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression expression ) + { + this( processor, IsNullPredicate.class, expression ); + } + + protected IsNullPredicateImpl( SQLProcessorAggregator processor, Class<? extends IsNullPredicate> predicateClass, + NonBooleanExpression expression ) + { + super( processor, predicateClass, expression ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LessOrEqualPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LessOrEqualPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LessOrEqualPredicateImpl.java new file mode 100644 index 0000000..31b8f91 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LessOrEqualPredicateImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.LessOrEqualPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class LessOrEqualPredicateImpl extends BinaryPredicateImpl<LessOrEqualPredicate> + implements LessOrEqualPredicate +{ + + public LessOrEqualPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, + NonBooleanExpression right ) + { + this( processor, LessOrEqualPredicate.class, left, right ); + } + + protected LessOrEqualPredicateImpl( SQLProcessorAggregator processor, + Class<? extends LessOrEqualPredicate> predicateClass, NonBooleanExpression left, NonBooleanExpression right ) + { + super( processor, predicateClass, left, right ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LessThanPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LessThanPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LessThanPredicateImpl.java new file mode 100644 index 0000000..feb1460 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LessThanPredicateImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.LessThanPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class LessThanPredicateImpl extends BinaryPredicateImpl<LessThanPredicate> + implements LessThanPredicate +{ + + public LessThanPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, + NonBooleanExpression right ) + { + this( processor, LessThanPredicate.class, left, right ); + } + + protected LessThanPredicateImpl( SQLProcessorAggregator processor, + Class<? extends LessThanPredicate> predicateClass, NonBooleanExpression left, NonBooleanExpression right ) + { + super( processor, predicateClass, left, right ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LikePredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LikePredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LikePredicateImpl.java new file mode 100644 index 0000000..a394ea0 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/LikePredicateImpl.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.LikePredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class LikePredicateImpl extends BinaryPredicateImpl<LikePredicate> + implements LikePredicate +{ + + public LikePredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, NonBooleanExpression right ) + { + this( processor, LikePredicate.class, left, right ); + } + + protected LikePredicateImpl( SQLProcessorAggregator processor, Class<? extends LikePredicate> predicateClass, + NonBooleanExpression left, NonBooleanExpression right ) + { + super( processor, predicateClass, left, right ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/MultiPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/MultiPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/MultiPredicateImpl.java new file mode 100644 index 0000000..ffdb5fc --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/MultiPredicateImpl.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.booleans.MultiPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public abstract class MultiPredicateImpl<ExpressionType extends MultiPredicate> extends + AbstractBooleanExpression<ExpressionType> + implements MultiPredicate +{ + + private final NonBooleanExpression _left; + + private final List<NonBooleanExpression> _rights; + + protected MultiPredicateImpl( SQLProcessorAggregator processor, Class<? extends ExpressionType> expressionClass, + NonBooleanExpression left, NonBooleanExpression... rights ) + { + this( processor, expressionClass, left, Arrays.asList( rights ) ); + } + + protected MultiPredicateImpl( SQLProcessorAggregator processor, Class<? extends ExpressionType> expressionClass, + NonBooleanExpression left, List<NonBooleanExpression> rights ) + { + super( processor, expressionClass ); + Objects.requireNonNull( left, "left" ); + Objects.requireNonNull( rights, "rights" ); + + for( NonBooleanExpression exp : rights ) + { + Objects.requireNonNull( exp, "right" ); + } + + this._left = left; + this._rights = Collections.unmodifiableList( rights ); + } + + public NonBooleanExpression getLeft() + { + return this._left; + } + + public List<NonBooleanExpression> getRights() + { + return this._rights; + } + + @Override + protected boolean doesEqual( ExpressionType another ) + { + return this._left.equals( another.getLeft() ) && this._rights.equals( another.getRights() ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NegationImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NegationImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NegationImpl.java new file mode 100644 index 0000000..8e294ec --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NegationImpl.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression; +import org.apache.polygene.library.sql.generator.grammar.booleans.Negation; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class NegationImpl extends ComposedBooleanExpressionImpl<Negation> + implements Negation +{ + + private final BooleanExpression _negated; + + public NegationImpl( SQLProcessorAggregator processor, BooleanExpression negated ) + { + this( processor, Negation.class, negated ); + } + + protected NegationImpl( SQLProcessorAggregator processor, Class<? extends Negation> negationClass, + BooleanExpression negated ) + { + super( processor, negationClass ); + Objects.requireNonNull( negated, "negated" ); + + this._negated = negated; + } + + public BooleanExpression getNegated() + { + return this._negated; + } + + public Iterator<BooleanExpression> iterator() + { + return Arrays.asList( this._negated ).iterator(); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotBetweenPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotBetweenPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotBetweenPredicateImpl.java new file mode 100644 index 0000000..d7b68ae --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotBetweenPredicateImpl.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.NotBetweenPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class NotBetweenPredicateImpl extends MultiPredicateImpl<NotBetweenPredicate> + implements NotBetweenPredicate +{ + + public NotBetweenPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, + NonBooleanExpression minimum, NonBooleanExpression maximum ) + { + this( processor, NotBetweenPredicate.class, left, minimum, maximum ); + } + + protected NotBetweenPredicateImpl( SQLProcessorAggregator processor, + Class<? extends NotBetweenPredicate> predicateClass, NonBooleanExpression left, NonBooleanExpression minimum, + NonBooleanExpression maximum ) + { + super( processor, predicateClass, left, minimum, maximum ); + } + + public NonBooleanExpression getMaximum() + { + return this.getRights().get( 1 ); + } + + public NonBooleanExpression getMinimum() + { + return this.getRights().get( 0 ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotEqualsPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotEqualsPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotEqualsPredicateImpl.java new file mode 100644 index 0000000..5a7e858 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotEqualsPredicateImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.NotEqualsPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class NotEqualsPredicateImpl extends BinaryPredicateImpl<NotEqualsPredicate> + implements NotEqualsPredicate +{ + + public NotEqualsPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, + NonBooleanExpression right ) + { + this( processor, NotEqualsPredicate.class, left, right ); + } + + protected NotEqualsPredicateImpl( SQLProcessorAggregator processor, + Class<? extends NotEqualsPredicate> predicateClass, NonBooleanExpression left, NonBooleanExpression right ) + { + super( processor, predicateClass, left, right ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotInPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotInPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotInPredicateImpl.java new file mode 100644 index 0000000..fe3a3af --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotInPredicateImpl.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import java.util.List; +import org.apache.polygene.library.sql.generator.grammar.booleans.NotInPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class NotInPredicateImpl extends MultiPredicateImpl<NotInPredicate> + implements NotInPredicate +{ + + public NotInPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, + List<NonBooleanExpression> rights ) + { + this( processor, NotInPredicate.class, left, rights ); + } + + protected NotInPredicateImpl( SQLProcessorAggregator processor, Class<? extends NotInPredicate> predicateClass, + NonBooleanExpression left, List<NonBooleanExpression> rights ) + { + super( processor, predicateClass, left, rights ); + } + + public NotInPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, + NonBooleanExpression... rights ) + { + this( processor, NotInPredicate.class, left, rights ); + } + + protected NotInPredicateImpl( SQLProcessorAggregator processor, Class<? extends NotInPredicate> predicateClass, + NonBooleanExpression left, NonBooleanExpression... rights ) + { + super( processor, predicateClass, left, rights ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotLikePredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotLikePredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotLikePredicateImpl.java new file mode 100644 index 0000000..0b18a78 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotLikePredicateImpl.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.NotLikePredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class NotLikePredicateImpl extends BinaryPredicateImpl<NotLikePredicate> + implements NotLikePredicate +{ + + public NotLikePredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, NonBooleanExpression right ) + { + this( processor, NotLikePredicate.class, left, right ); + } + + protected NotLikePredicateImpl( SQLProcessorAggregator processor, Class<? extends NotLikePredicate> predicateClass, + NonBooleanExpression left, NonBooleanExpression right ) + { + super( processor, predicateClass, left, right ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotRegexpPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotRegexpPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotRegexpPredicateImpl.java new file mode 100644 index 0000000..3f86c30 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/NotRegexpPredicateImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.NotRegexpPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class NotRegexpPredicateImpl extends BinaryPredicateImpl<NotRegexpPredicate> + implements NotRegexpPredicate +{ + + public NotRegexpPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, + NonBooleanExpression right ) + { + this( processor, NotRegexpPredicate.class, left, right ); + } + + protected NotRegexpPredicateImpl( SQLProcessorAggregator processor, + Class<? extends NotRegexpPredicate> predicateClass, NonBooleanExpression left, NonBooleanExpression right ) + { + super( processor, predicateClass, left, right ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/RegexpPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/RegexpPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/RegexpPredicateImpl.java new file mode 100644 index 0000000..f725100 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/RegexpPredicateImpl.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.RegexpPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class RegexpPredicateImpl extends BinaryPredicateImpl<RegexpPredicate> + implements RegexpPredicate +{ + + public RegexpPredicateImpl( SQLProcessorAggregator processor, NonBooleanExpression left, NonBooleanExpression right ) + { + this( processor, RegexpPredicate.class, left, right ); + } + + protected RegexpPredicateImpl( SQLProcessorAggregator processor, Class<? extends RegexpPredicate> predicateClass, + NonBooleanExpression left, NonBooleanExpression right ) + { + super( processor, predicateClass, left, right ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/UnaryPredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/UnaryPredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/UnaryPredicateImpl.java new file mode 100644 index 0000000..3c26361 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/UnaryPredicateImpl.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.booleans.UnaryPredicate; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public abstract class UnaryPredicateImpl<ExpressionType extends UnaryPredicate> extends + AbstractBooleanExpression<ExpressionType> + implements UnaryPredicate +{ + + private final NonBooleanExpression _expression; + + public UnaryPredicateImpl( SQLProcessorAggregator processor, Class<? extends ExpressionType> expressionClass, + NonBooleanExpression expression ) + { + super( processor, expressionClass ); + Objects.requireNonNull( expression, "expression" ); + + this._expression = expression; + } + + public NonBooleanExpression getValueExpression() + { + return this._expression; + } + + @Override + protected boolean doesEqual( ExpressionType another ) + { + return this._expression.equals( another.getValueExpression() ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/UniquePredicateImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/UniquePredicateImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/UniquePredicateImpl.java new file mode 100644 index 0000000..19f96fe --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/UniquePredicateImpl.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.booleans; + +import org.apache.polygene.library.sql.generator.grammar.booleans.UniquePredicate; +import org.apache.polygene.library.sql.generator.grammar.query.QueryExpression; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class UniquePredicateImpl extends UnaryPredicateImpl<UniquePredicate> + implements UniquePredicate +{ + + public UniquePredicateImpl( SQLProcessorAggregator processor, QueryExpression query ) + { + this( processor, UniquePredicate.class, query ); + } + + protected UniquePredicateImpl( SQLProcessorAggregator processor, Class<? extends UniquePredicate> predicateClass, + QueryExpression query ) + { + super( processor, predicateClass, query ); + } + + @Override + public QueryExpression getValueExpression() + { + return (QueryExpression) super.getValueExpression(); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/booleans/BooleanBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/booleans/BooleanBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/booleans/BooleanBuilderImpl.java new file mode 100644 index 0000000..450e263 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/booleans/BooleanBuilderImpl.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.booleans; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression; +import org.apache.polygene.library.sql.generator.grammar.booleans.Predicate; +import org.apache.polygene.library.sql.generator.grammar.builders.booleans.BooleanBuilder; +import org.apache.polygene.library.sql.generator.grammar.factories.BooleanFactory; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class BooleanBuilderImpl extends SQLBuilderBase + implements BooleanBuilder +{ + + private BooleanExpression _topLevelExpression; + + private final BooleanFactory _factory; + + public BooleanBuilderImpl( SQLProcessorAggregator processor, BooleanFactory factory ) + { + this( processor, factory, Predicate.EmptyPredicate.INSTANCE ); + } + + public BooleanBuilderImpl( SQLProcessorAggregator processor, BooleanFactory factory, BooleanExpression expression ) + { + super( processor ); + Objects.requireNonNull( factory, "boolean expression factory" ); + + this._factory = factory; + this._topLevelExpression = expression; + } + + public BooleanBuilder and( BooleanExpression next ) + { + this._topLevelExpression = this._factory.and( this._topLevelExpression, next ); + return this; + } + + public BooleanBuilder or( BooleanExpression next ) + { + this._topLevelExpression = this._factory.or( this._topLevelExpression, next ); + return this; + } + + public BooleanBuilder not() + { + this._topLevelExpression = this._factory.not( this._topLevelExpression ); + return this; + } + + public BooleanBuilder reset( BooleanExpression newExpression ) + { + this._topLevelExpression = newExpression; + return this; + } + + public BooleanExpression createExpression() + { + return this._topLevelExpression == null ? Predicate.EmptyPredicate.INSTANCE : this._topLevelExpression; + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/booleans/InBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/booleans/InBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/booleans/InBuilderImpl.java new file mode 100644 index 0000000..9c6b290 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/booleans/InBuilderImpl.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.booleans; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.booleans.InPredicate; +import org.apache.polygene.library.sql.generator.grammar.builders.booleans.InBuilder; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.implementation.grammar.booleans.InPredicateImpl; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class InBuilderImpl extends SQLBuilderBase + implements InBuilder +{ + + private final NonBooleanExpression _left; + + private final List<NonBooleanExpression> _expressions; + + public InBuilderImpl( SQLProcessorAggregator processor, NonBooleanExpression left ) + { + super( processor ); + Objects.requireNonNull( left, "left" ); + + this._left = left; + this._expressions = new ArrayList<NonBooleanExpression>(); + } + + public InBuilder addValues( NonBooleanExpression... expressions ) + { + Objects.requireNonNull( expressions, "expressions" ); + for( NonBooleanExpression exp : expressions ) + { + Objects.requireNonNull( exp, "expression" ); + } + + this._expressions.addAll( Arrays.asList( expressions ) ); + return this; + } + + public InPredicate createExpression() + { + return new InPredicateImpl( this.getProcessor(), this._left, this._expressions ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/ForeignKeyConstraintBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/ForeignKeyConstraintBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/ForeignKeyConstraintBuilderImpl.java new file mode 100644 index 0000000..5d4051e --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/ForeignKeyConstraintBuilderImpl.java @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.definition; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.builders.definition.ForeignKeyConstraintBuilder; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.definition.table.ForeignKeyConstraint; +import org.apache.polygene.library.sql.generator.grammar.definition.table.MatchType; +import org.apache.polygene.library.sql.generator.grammar.definition.table.ReferentialAction; +import org.apache.polygene.library.sql.generator.grammar.factories.ColumnsFactory; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.grammar.definition.table.ForeignKeyConstraintImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class ForeignKeyConstraintBuilderImpl extends SQLBuilderBase + implements ForeignKeyConstraintBuilder +{ + + private final List<String> _sourceColumns; + private final List<String> _targetColumns; + private TableNameDirect _targetTable; + private MatchType _matchType; + private ReferentialAction _onUpdate; + private ReferentialAction _onDelete; + + private final ColumnsFactory _c; + + public ForeignKeyConstraintBuilderImpl( SQLProcessorAggregator processor, ColumnsFactory c ) + { + super( processor ); + Objects.requireNonNull( c, "Columns factory" ); + + this._c = c; + + this._sourceColumns = new ArrayList<String>(); + this._targetColumns = new ArrayList<String>(); + } + + public ForeignKeyConstraint createExpression() + { + return new ForeignKeyConstraintImpl( this.getProcessor(), this._c.colNames( this._sourceColumns ), + this._targetTable, this._targetColumns.size() == 0 ? null : this._c.colNames( this._targetColumns ), + this._matchType, this._onDelete, this._onUpdate ); + } + + public ForeignKeyConstraintBuilder addSourceColumns( String... columnNames ) + { + for( String name : columnNames ) + { + this._sourceColumns.add( name ); + } + return this; + } + + public ForeignKeyConstraintBuilder addTargetColumns( String... columnNames ) + { + for( String name : columnNames ) + { + this._targetColumns.add( name ); + } + return this; + } + + public ForeignKeyConstraintBuilder setTargetTableName( TableNameDirect tableName ) + { + this._targetTable = tableName; + return this; + } + + public ForeignKeyConstraintBuilder setMatchType( MatchType matchType ) + { + this._matchType = matchType; + return this; + } + + public ForeignKeyConstraintBuilder setOnUpdate( ReferentialAction action ) + { + this._onUpdate = action; + return this; + } + + public ForeignKeyConstraintBuilder setOnDelete( ReferentialAction action ) + { + this._onDelete = action; + return this; + } + + public List<String> getSourceColumns() + { + return this._sourceColumns; + } + + public List<String> getTargetColumns() + { + return this._targetColumns; + } + + public TableNameDirect getTableName() + { + return this._targetTable; + } + + public MatchType getMatchType() + { + return this._matchType; + } + + public ReferentialAction getOnUpdate() + { + return this._onUpdate; + } + + public ReferentialAction getOnDelete() + { + return this._onDelete; + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/SchemaDefinitionBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/SchemaDefinitionBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/SchemaDefinitionBuilderImpl.java new file mode 100644 index 0000000..f8aa750 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/SchemaDefinitionBuilderImpl.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.definition; + +import java.util.ArrayList; +import java.util.List; +import org.apache.polygene.library.sql.generator.grammar.builders.definition.SchemaDefinitionBuilder; +import org.apache.polygene.library.sql.generator.grammar.definition.schema.SchemaDefinition; +import org.apache.polygene.library.sql.generator.grammar.definition.schema.SchemaElement; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.grammar.definition.schema.SchemaDefinitionImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class SchemaDefinitionBuilderImpl extends SQLBuilderBase + implements SchemaDefinitionBuilder +{ + + private String _schemaName; + private String _schemaCharset; + private final List<SchemaElement> _elements; + + public SchemaDefinitionBuilderImpl( SQLProcessorAggregator processor ) + { + super( processor ); + this._elements = new ArrayList<SchemaElement>(); + } + + public SchemaDefinition createExpression() + { + return new SchemaDefinitionImpl( this.getProcessor(), this._schemaName, this._schemaCharset, this._elements ); + } + + public SchemaDefinitionBuilder setSchemaName( String schemaName ) + { + this._schemaName = schemaName; + return this; + } + + public SchemaDefinitionBuilder setSchemaCharset( String charset ) + { + this._schemaCharset = charset; + return this; + } + + public SchemaDefinitionBuilder addSchemaElements( SchemaElement... elements ) + { + for( SchemaElement el : elements ) + { + this._elements.add( el ); + } + return this; + } + + public String getSchemaName() + { + return this._schemaName; + } + + public String getSchemaCharset() + { + return this._schemaCharset; + } + + public List<SchemaElement> getSchemaElements() + { + return this._elements; + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/TableDefinitionBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/TableDefinitionBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/TableDefinitionBuilderImpl.java new file mode 100644 index 0000000..d4f5241 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/TableDefinitionBuilderImpl.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.definition; + +import org.apache.polygene.library.sql.generator.grammar.builders.definition.TableDefinitionBuilder; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.definition.table.TableCommitAction; +import org.apache.polygene.library.sql.generator.grammar.definition.table.TableContentsSource; +import org.apache.polygene.library.sql.generator.grammar.definition.table.TableDefinition; +import org.apache.polygene.library.sql.generator.grammar.definition.table.TableScope; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.grammar.definition.table.TableDefinitionImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class TableDefinitionBuilderImpl extends SQLBuilderBase + implements TableDefinitionBuilder +{ + + private TableScope _scope; + private TableNameDirect _name; + private TableCommitAction _commitAction; + private TableContentsSource _contents; + + public TableDefinitionBuilderImpl( SQLProcessorAggregator processor ) + { + super( processor ); + } + + public TableDefinition createExpression() + { + return new TableDefinitionImpl( this.getProcessor(), this._commitAction, this._contents, this._name, + this._scope ); + } + + public TableDefinitionBuilder setTableScope( TableScope scope ) + { + this._scope = scope; + return this; + } + + public TableDefinitionBuilder setTableName( TableNameDirect tableName ) + { + this._name = tableName; + return this; + } + + public TableDefinitionBuilder setCommitAction( TableCommitAction commitAction ) + { + this._commitAction = commitAction; + return this; + } + + public TableDefinitionBuilder setTableContentsSource( TableContentsSource contents ) + { + this._contents = contents; + return this; + } + + public TableScope getTableScope() + { + return this._scope; + } + + public TableNameDirect getTableName() + { + return this._name; + } + + public TableCommitAction getCommitAction() + { + return this._commitAction; + } + + public TableContentsSource getTableContentsSource() + { + return this._contents; + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/TableElementListBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/TableElementListBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/TableElementListBuilderImpl.java new file mode 100644 index 0000000..0798a66 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/TableElementListBuilderImpl.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.definition; + +import java.util.ArrayList; +import java.util.List; +import org.apache.polygene.library.sql.generator.grammar.builders.definition.TableElementListBuilder; +import org.apache.polygene.library.sql.generator.grammar.definition.table.TableElement; +import org.apache.polygene.library.sql.generator.grammar.definition.table.TableElementList; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.grammar.definition.table.TableElementListImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class TableElementListBuilderImpl extends SQLBuilderBase + implements TableElementListBuilder +{ + + private final List<TableElement> _elements; + + public TableElementListBuilderImpl( SQLProcessorAggregator processor ) + { + super( processor ); + this._elements = new ArrayList<TableElement>(); + } + + public TableElementList createExpression() + { + return new TableElementListImpl( this.getProcessor(), this._elements ); + } + + public TableElementListBuilder addTableElement( TableElement element ) + { + this._elements.add( element ); + return this; + } + + public List<TableElement> getTableElements() + { + return this._elements; + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/UniqueConstraintBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/UniqueConstraintBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/UniqueConstraintBuilderImpl.java new file mode 100644 index 0000000..9668a2c --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/UniqueConstraintBuilderImpl.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.definition; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.builders.definition.UniqueConstraintBuilder; +import org.apache.polygene.library.sql.generator.grammar.definition.table.UniqueConstraint; +import org.apache.polygene.library.sql.generator.grammar.definition.table.UniqueSpecification; +import org.apache.polygene.library.sql.generator.grammar.factories.ColumnsFactory; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.grammar.definition.table.UniqueConstraintImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class UniqueConstraintBuilderImpl extends SQLBuilderBase + implements UniqueConstraintBuilder +{ + + private UniqueSpecification _uniqueness; + private final List<String> _columns; + + private final ColumnsFactory _c; + + public UniqueConstraintBuilderImpl( SQLProcessorAggregator processor, ColumnsFactory c ) + { + super( processor ); + Objects.requireNonNull( c, "Columns factory" ); + + this._c = c; + this._columns = new ArrayList<String>(); + } + + public UniqueConstraint createExpression() + { + return new UniqueConstraintImpl( this.getProcessor(), this._c.colNames( this._columns ), this._uniqueness ); + } + + public UniqueConstraintBuilder setUniqueness( UniqueSpecification uniqueness ) + { + this._uniqueness = uniqueness; + return this; + } + + public UniqueConstraintBuilder addColumns( String... columnNames ) + { + for( String col : columnNames ) + { + this._columns.add( col ); + } + return this; + } + + public UniqueSpecification getUniqueness() + { + return this._uniqueness; + } + + public List<String> getColumns() + { + return this._columns; + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/ViewDefinitionBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/ViewDefinitionBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/ViewDefinitionBuilderImpl.java new file mode 100644 index 0000000..f3dd53e --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/definition/ViewDefinitionBuilderImpl.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.definition; + +import org.apache.polygene.library.sql.generator.grammar.builders.definition.ViewDefinitionBuilder; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.definition.view.ViewCheckOption; +import org.apache.polygene.library.sql.generator.grammar.definition.view.ViewDefinition; +import org.apache.polygene.library.sql.generator.grammar.definition.view.ViewSpecification; +import org.apache.polygene.library.sql.generator.grammar.query.QueryExpression; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.grammar.definition.view.ViewDefinitionImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class ViewDefinitionBuilderImpl extends SQLBuilderBase + implements ViewDefinitionBuilder +{ + + private Boolean _isRecursive; + private TableNameDirect _name; + private QueryExpression _query; + private ViewCheckOption _viewCheck; + private ViewSpecification _viewSpec; + + public ViewDefinitionBuilderImpl( SQLProcessorAggregator processor ) + { + super( processor ); + } + + public ViewDefinition createExpression() + { + return new ViewDefinitionImpl( this.getProcessor(), this._name, this._query, this._viewSpec, this._viewCheck, + this._isRecursive ); + } + + public ViewDefinitionBuilder setRecursive( Boolean isRecursive ) + { + this._isRecursive = isRecursive; + return this; + } + + public ViewDefinitionBuilder setViewName( TableNameDirect viewName ) + { + this._name = viewName; + return this; + } + + public ViewDefinitionBuilder setQuery( QueryExpression query ) + { + this._query = query; + return this; + } + + public ViewDefinitionBuilder setViewCheckOption( ViewCheckOption viewCheck ) + { + this._viewCheck = viewCheck; + return this; + } + + public ViewDefinitionBuilder setViewSpecification( ViewSpecification spec ) + { + this._viewSpec = spec; + return this; + } + + public Boolean isRecursive() + { + return this._isRecursive; + } + + public TableNameDirect getViewName() + { + return this._name; + } + + public QueryExpression getQueryExpression() + { + return this._query; + } + + public ViewCheckOption getViewCheckOption() + { + return this._viewCheck; + } + + public ViewSpecification getViewSpecification() + { + return this._viewSpec; + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/modification/ColumnSourceByValuesBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/modification/ColumnSourceByValuesBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/modification/ColumnSourceByValuesBuilderImpl.java new file mode 100644 index 0000000..f106dbf --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/modification/ColumnSourceByValuesBuilderImpl.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.modification; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.builders.modification.ColumnSourceByValuesBuilder; +import org.apache.polygene.library.sql.generator.grammar.common.ColumnNameList; +import org.apache.polygene.library.sql.generator.grammar.common.ValueExpression; +import org.apache.polygene.library.sql.generator.grammar.modification.ColumnSourceByValues; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.ColumnNameListImpl; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.grammar.modification.ColumnSourceByValuesImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class ColumnSourceByValuesBuilderImpl extends SQLBuilderBase + implements ColumnSourceByValuesBuilder +{ + + private final List<ValueExpression> _values; + + private final List<String> _columnNames; + + public ColumnSourceByValuesBuilderImpl( SQLProcessorAggregator processor ) + { + super( processor ); + this._values = new ArrayList<ValueExpression>(); + this._columnNames = new ArrayList<String>(); + } + + public ColumnSourceByValues createExpression() + { + ColumnNameList list = null; + if( !this._columnNames.isEmpty() ) + { + list = new ColumnNameListImpl( this.getProcessor(), this._columnNames ); + } + return new ColumnSourceByValuesImpl( this.getProcessor(), list, this._values ); + } + + public ColumnSourceByValuesBuilder addValues( ValueExpression... values ) + { + for( ValueExpression exp : values ) + { + Objects.requireNonNull( exp, "value" ); + this._values.add( exp ); + } + return this; + } + + public List<ValueExpression> getValues() + { + return Collections.unmodifiableList( this._values ); + } + + public ColumnSourceByValuesBuilder addColumnNames( String... columnNames ) + { + for( String str : columnNames ) + { + Objects.requireNonNull( str, "column name" ); + this._columnNames.add( str ); + } + + return this; + } + + public List<String> getColumnNames() + { + return Collections.unmodifiableList( this._columnNames ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/modification/DeleteBySearchBuilderImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/modification/DeleteBySearchBuilderImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/modification/DeleteBySearchBuilderImpl.java new file mode 100644 index 0000000..b5dade8 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/builders/modification/DeleteBySearchBuilderImpl.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.library.sql.generator.implementation.grammar.builders.modification; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.builders.booleans.BooleanBuilder; +import org.apache.polygene.library.sql.generator.grammar.builders.modification.DeleteBySearchBuilder; +import org.apache.polygene.library.sql.generator.grammar.modification.DeleteBySearch; +import org.apache.polygene.library.sql.generator.grammar.modification.TargetTable; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLBuilderBase; +import org.apache.polygene.library.sql.generator.implementation.grammar.modification.DeleteBySearchImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class DeleteBySearchBuilderImpl extends SQLBuilderBase + implements DeleteBySearchBuilder +{ + + private final BooleanBuilder _whereBuilder; + + private TargetTable _targetTable; + + public DeleteBySearchBuilderImpl( SQLProcessorAggregator processor, BooleanBuilder whereBuilder ) + { + super( processor ); + Objects.requireNonNull( whereBuilder, "where builder" ); + this._whereBuilder = whereBuilder; + } + + public DeleteBySearch createExpression() + { + + return new DeleteBySearchImpl( this.getProcessor(), this._targetTable, this._whereBuilder.createExpression() ); + } + + public DeleteBySearchBuilder setTargetTable( TargetTable table ) + { + Objects.requireNonNull( table, "table" ); + this._targetTable = table; + return this; + } + + public TargetTable getTargetTable() + { + return this._targetTable; + } + + public BooleanBuilder getWhere() + { + return this._whereBuilder; + } +}
