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/factories/pgsql/PgSQLDataTypeFactoryImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLDataTypeFactoryImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLDataTypeFactoryImpl.java new file mode 100644 index 0000000..2cbc4ae --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLDataTypeFactoryImpl.java @@ -0,0 +1,45 @@ +/* + * 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.factories.pgsql; + +import org.apache.polygene.library.sql.generator.grammar.common.datatypes.pgsql.Text; +import org.apache.polygene.library.sql.generator.grammar.factories.pgsql.PgSQLDataTypeFactory; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.datatypes.pgsql.TextImpl; +import org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultDataTypeFactory; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; +import org.apache.polygene.library.sql.generator.vendor.PostgreSQLVendor; + +/** + * @author Stanislav Muhametsin + */ +public class PgSQLDataTypeFactoryImpl extends DefaultDataTypeFactory + implements PgSQLDataTypeFactory +{ + + public PgSQLDataTypeFactoryImpl( PostgreSQLVendor vendor, SQLProcessorAggregator processor ) + { + super( vendor, processor ); + } + + public Text text() + { + return TextImpl.INSTANCE; + } +}
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/factories/pgsql/PgSQLManipulationFactoryImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLManipulationFactoryImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLManipulationFactoryImpl.java new file mode 100644 index 0000000..52c43ce --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLManipulationFactoryImpl.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.factories.pgsql; + +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.factories.pgsql.PgSQLManipulationFactory; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropBehaviour; +import org.apache.polygene.library.sql.generator.grammar.manipulation.ObjectType; +import org.apache.polygene.library.sql.generator.grammar.manipulation.pgsql.PgSQLDropTableOrViewStatement; +import org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultManipulationFactory; +import org.apache.polygene.library.sql.generator.implementation.grammar.manipulation.pgsql.PgSQLDropTableOrViewStatementImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; +import org.apache.polygene.library.sql.generator.vendor.PostgreSQLVendor; + +/** + * @author Stanislav Muhametsin + */ +public class PgSQLManipulationFactoryImpl extends DefaultManipulationFactory + implements PgSQLManipulationFactory +{ + public PgSQLManipulationFactoryImpl( PostgreSQLVendor vendor, SQLProcessorAggregator processor ) + { + super( vendor, processor ); + } + + @Override + public PgSQLDropTableOrViewStatement createDropTableOrViewStatement( TableNameDirect tableName, ObjectType theType, + DropBehaviour dropBehaviour ) + { + return this.createDropTableOrViewStatement( tableName, theType, dropBehaviour, false ); + } + + public PgSQLDropTableOrViewStatement createDropTableOrViewStatement( TableNameDirect tableName, ObjectType theType, + DropBehaviour dropBehaviour, Boolean useIfExists ) + { + return new PgSQLDropTableOrViewStatementImpl( this.getProcessor(), theType, dropBehaviour, tableName, + useIfExists ); + } +} 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/factories/pgsql/PgSQLModificationFactoryImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLModificationFactoryImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLModificationFactoryImpl.java new file mode 100644 index 0000000..18905ec --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/factories/pgsql/PgSQLModificationFactoryImpl.java @@ -0,0 +1,41 @@ +/* + * 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.factories.pgsql; + +import org.apache.polygene.library.sql.generator.grammar.builders.modification.InsertStatementBuilder; +import org.apache.polygene.library.sql.generator.implementation.grammar.builders.modification.pgsql.PgSQLInsertStatementBuilderImpl; +import org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultModificationFactory; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; +import org.apache.polygene.library.sql.generator.vendor.PostgreSQLVendor; + +public class PgSQLModificationFactoryImpl extends DefaultModificationFactory +{ + + public PgSQLModificationFactoryImpl( PostgreSQLVendor vendor, SQLProcessorAggregator processor ) + { + super( vendor, processor ); + } + + @Override + public InsertStatementBuilder insert() + { + return new PgSQLInsertStatementBuilderImpl( this.getProcessor() ); + } +} 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/literals/DirectLiteralImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/DirectLiteralImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/DirectLiteralImpl.java new file mode 100644 index 0000000..f2fc875 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/DirectLiteralImpl.java @@ -0,0 +1,59 @@ +/* + * 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.literals; + +import org.apache.polygene.library.sql.generator.grammar.literals.DirectLiteral; +import org.apache.polygene.library.sql.generator.implementation.TypeableImpl; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.NonBooleanExpressionImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class DirectLiteralImpl extends NonBooleanExpressionImpl<DirectLiteral> + implements DirectLiteral +{ + + private final String _literal; + + public DirectLiteralImpl( SQLProcessorAggregator processor, String literal ) + { + this( processor, DirectLiteral.class, literal ); + } + + protected DirectLiteralImpl( SQLProcessorAggregator processor, Class<? extends DirectLiteral> implClass, + String literal ) + { + super( processor, implClass ); + + this._literal = literal; + } + + public String getDirectLiteral() + { + return this._literal; + } + + @Override + protected boolean doesEqual( DirectLiteral another ) + { + return TypeableImpl.bothNullOrEquals( this._literal, another.getDirectLiteral() ); + } +} 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/literals/NumericLiteralImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/NumericLiteralImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/NumericLiteralImpl.java new file mode 100644 index 0000000..bc714c2 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/NumericLiteralImpl.java @@ -0,0 +1,59 @@ +/* + * 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.literals; + +import org.apache.polygene.library.sql.generator.grammar.literals.NumericLiteral; +import org.apache.polygene.library.sql.generator.implementation.TypeableImpl; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.NonBooleanExpressionImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class NumericLiteralImpl extends NonBooleanExpressionImpl<NumericLiteral> + implements NumericLiteral +{ + + private final Number _number; + + public NumericLiteralImpl( SQLProcessorAggregator processor, Number number ) + { + this( processor, NumericLiteral.class, number ); + } + + protected NumericLiteralImpl( SQLProcessorAggregator processor, Class<? extends NumericLiteral> implClass, + Number number ) + { + super( processor, implClass ); + + this._number = number; + } + + public Number getNumber() + { + return this._number; + } + + @Override + protected boolean doesEqual( NumericLiteral another ) + { + return TypeableImpl.bothNullOrEquals( this._number, another.getNumber() ); + } +} 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/literals/SQLFunctionLiteralImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/SQLFunctionLiteralImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/SQLFunctionLiteralImpl.java new file mode 100644 index 0000000..e397e2f --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/SQLFunctionLiteralImpl.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.literals; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.common.ValueExpression; +import org.apache.polygene.library.sql.generator.grammar.literals.SQLFunctionLiteral; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.NonBooleanExpressionImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class SQLFunctionLiteralImpl extends NonBooleanExpressionImpl<SQLFunctionLiteral> + implements SQLFunctionLiteral +{ + + private final String _name; + + private final List<ValueExpression> _parameters; + + public SQLFunctionLiteralImpl( SQLProcessorAggregator processor, String name, ValueExpression... parameters ) + { + this( processor, name, Arrays.asList( parameters ) ); + } + + public SQLFunctionLiteralImpl( SQLProcessorAggregator processor, String name, List<ValueExpression> parameters ) + { + this( processor, SQLFunctionLiteral.class, name, parameters ); + } + + protected SQLFunctionLiteralImpl( SQLProcessorAggregator processor, Class<? extends SQLFunctionLiteral> implClass, + String name, List<ValueExpression> parameters ) + { + super( processor, implClass ); + Objects.requireNonNull( name, "name" ); + Objects.requireNonNull( parameters, "parameters" ); + for( ValueExpression exp : parameters ) + { + Objects.requireNonNull( exp, "parameter" ); + } + + this._name = name; + this._parameters = Collections.unmodifiableList( new ArrayList<ValueExpression>( parameters ) ); + } + + public String getFunctionName() + { + return this._name; + } + + public List<ValueExpression> getParameters() + { + return this._parameters; + } + + @Override + protected boolean doesEqual( SQLFunctionLiteral another ) + { + return this._name.equals( another.getFunctionName() ) && this._parameters.equals( another.getParameters() ); + } +} 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/literals/StringLiteralImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/StringLiteralImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/StringLiteralImpl.java new file mode 100644 index 0000000..fa3b075 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/StringLiteralImpl.java @@ -0,0 +1,60 @@ +/* + * 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.literals; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.literals.StringLiteral; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.NonBooleanExpressionImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class StringLiteralImpl extends NonBooleanExpressionImpl<StringLiteral> + implements StringLiteral +{ + + private final String _literal; + + public StringLiteralImpl( SQLProcessorAggregator processor, String literal ) + { + this( processor, StringLiteral.class, literal ); + } + + protected StringLiteralImpl( SQLProcessorAggregator processor, Class<? extends StringLiteral> implClass, + String literal ) + { + super( processor, implClass ); + Objects.requireNonNull( literal, "literal" ); + + this._literal = literal; + } + + public String getString() + { + return this._literal; + } + + @Override + protected boolean doesEqual( StringLiteral another ) + { + return this._literal.equals( another.getString() ); + } +} 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/literals/TimestampLiteralImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/TimestampLiteralImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/TimestampLiteralImpl.java new file mode 100644 index 0000000..8245bd1 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/literals/TimestampLiteralImpl.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.literals; + +import java.sql.Timestamp; +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.literals.TimestampTimeLiteral; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.NonBooleanExpressionImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class TimestampLiteralImpl extends NonBooleanExpressionImpl<TimestampTimeLiteral> + implements TimestampTimeLiteral +{ + + private final Timestamp _date; + + public TimestampLiteralImpl( SQLProcessorAggregator processor, Timestamp date ) + { + this( processor, TimestampTimeLiteral.class, date ); + } + + protected TimestampLiteralImpl( SQLProcessorAggregator processor, Class<? extends TimestampTimeLiteral> implClass, + Timestamp date ) + { + super( processor, implClass ); + + Objects.requireNonNull( date, "Timestamp" ); + this._date = date; + } + + public Timestamp getTimestamp() + { + return this._date; + } + + @Override + protected boolean doesEqual( TimestampTimeLiteral another ) + { + return this._date.equals( another.getTimestamp() ); + } +} 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/manipulation/AddColumnDefinitionImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AddColumnDefinitionImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AddColumnDefinitionImpl.java new file mode 100644 index 0000000..4400ebc --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AddColumnDefinitionImpl.java @@ -0,0 +1,63 @@ +/* + * 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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.definition.table.ColumnDefinition; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AddColumnDefinition; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterTableAction; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class AddColumnDefinitionImpl extends SQLSyntaxElementBase<AlterTableAction, AddColumnDefinition> + implements AddColumnDefinition +{ + + private final ColumnDefinition _columnDefinition; + + public AddColumnDefinitionImpl( SQLProcessorAggregator processor, ColumnDefinition columnDefinition ) + { + this( processor, AddColumnDefinition.class, columnDefinition ); + } + + protected AddColumnDefinitionImpl( SQLProcessorAggregator processor, + Class<? extends AddColumnDefinition> realImplementingType, ColumnDefinition columnDefinition ) + { + super( processor, realImplementingType ); + + Objects.requireNonNull( columnDefinition, "Column definition" ); + + this._columnDefinition = columnDefinition; + } + + @Override + protected boolean doesEqual( AddColumnDefinition another ) + { + return this._columnDefinition.equals( another.getColumnDefinition() ); + } + + public ColumnDefinition getColumnDefinition() + { + return this._columnDefinition; + } +} 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/manipulation/AddTableConstraintDefinitionImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AddTableConstraintDefinitionImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AddTableConstraintDefinitionImpl.java new file mode 100644 index 0000000..d23ddf3 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AddTableConstraintDefinitionImpl.java @@ -0,0 +1,62 @@ +/* + * 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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.definition.table.TableConstraintDefinition; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AddTableConstraintDefinition; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterTableAction; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class AddTableConstraintDefinitionImpl extends + SQLSyntaxElementBase<AlterTableAction, AddTableConstraintDefinition> + implements AddTableConstraintDefinition +{ + + private final TableConstraintDefinition _constraint; + + public AddTableConstraintDefinitionImpl( SQLProcessorAggregator processor, TableConstraintDefinition constraint ) + { + this( processor, AddTableConstraintDefinition.class, constraint ); + } + + protected AddTableConstraintDefinitionImpl( SQLProcessorAggregator processor, + Class<? extends AddTableConstraintDefinition> realImplementingType, TableConstraintDefinition constraint ) + { + super( processor, realImplementingType ); + Objects.requireNonNull( constraint, "Constraint" ); + this._constraint = constraint; + } + + @Override + protected boolean doesEqual( AddTableConstraintDefinition another ) + { + return this._constraint.equals( another.getConstraint() ); + } + + public TableConstraintDefinition getConstraint() + { + return this._constraint; + } +} 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/manipulation/AlterColumnDefinitionImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AlterColumnDefinitionImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AlterColumnDefinitionImpl.java new file mode 100644 index 0000000..5689e9c --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AlterColumnDefinitionImpl.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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterColumnAction; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterColumnDefinition; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterTableAction; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class AlterColumnDefinitionImpl extends SQLSyntaxElementBase<AlterTableAction, AlterColumnDefinition> + implements AlterColumnDefinition +{ + + private final String _columnName; + private final AlterColumnAction _action; + + public AlterColumnDefinitionImpl( SQLProcessorAggregator processor, String columnName, AlterColumnAction action ) + { + this( processor, AlterColumnDefinition.class, columnName, action ); + } + + protected AlterColumnDefinitionImpl( SQLProcessorAggregator processor, + Class<? extends AlterColumnDefinition> realImplementingType, String columnName, AlterColumnAction action ) + { + super( processor, realImplementingType ); + Objects.requireNonNull( columnName, "Column name" ); + Objects.requireNonNull( action, "Alter column action" ); + this._columnName = columnName; + this._action = action; + } + + @Override + protected boolean doesEqual( AlterColumnDefinition another ) + { + return this._columnName.equals( another.getColumnName() ) && this._action.equals( another.getAction() ); + } + + public AlterColumnAction getAction() + { + return this._action; + } + + public String getColumnName() + { + return this._columnName; + } +} 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/manipulation/AlterTableStatementImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AlterTableStatementImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AlterTableStatementImpl.java new file mode 100644 index 0000000..284ac6d --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/AlterTableStatementImpl.java @@ -0,0 +1,70 @@ +/* + * 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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.common.SchemaStatement; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterTableAction; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterTableStatement; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class AlterTableStatementImpl extends SQLSyntaxElementBase<SchemaStatement, AlterTableStatement> + implements AlterTableStatement +{ + + private final TableNameDirect _tableName; + private final AlterTableAction _action; + + public AlterTableStatementImpl( SQLProcessorAggregator processor, TableNameDirect tableName, AlterTableAction action ) + { + this( processor, AlterTableStatement.class, tableName, action ); + } + + protected AlterTableStatementImpl( SQLProcessorAggregator processor, + Class<? extends AlterTableStatement> realImplementingType, TableNameDirect tableName, AlterTableAction action ) + { + super( processor, realImplementingType ); + Objects.requireNonNull( tableName, "Table name" ); + Objects.requireNonNull( action, "Alter table taction" ); + this._tableName = tableName; + this._action = action; + } + + @Override + protected boolean doesEqual( AlterTableStatement another ) + { + return this._tableName.equals( another.getTableName() ) && this._action.equals( another.getAction() ); + } + + public AlterTableAction getAction() + { + return this._action; + } + + public TableNameDirect getTableName() + { + return this._tableName; + } +} 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/manipulation/DropColumnDefinitionImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropColumnDefinitionImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropColumnDefinitionImpl.java new file mode 100644 index 0000000..3db7753 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropColumnDefinitionImpl.java @@ -0,0 +1,70 @@ +/* + * 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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterTableAction; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropBehaviour; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropColumnDefinition; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class DropColumnDefinitionImpl extends SQLSyntaxElementBase<AlterTableAction, DropColumnDefinition> + implements DropColumnDefinition +{ + + private final String _columnName; + private final DropBehaviour _dropBehaviour; + + public DropColumnDefinitionImpl( SQLProcessorAggregator processor, String columnName, DropBehaviour dropBehaviour ) + { + this( processor, DropColumnDefinition.class, columnName, dropBehaviour ); + } + + protected DropColumnDefinitionImpl( SQLProcessorAggregator processor, + Class<? extends DropColumnDefinition> realImplementingType, String columnName, DropBehaviour dropBehaviour ) + { + super( processor, realImplementingType ); + Objects.requireNonNull( columnName, "Column name" ); + Objects.requireNonNull( dropBehaviour, "Drop behaviour" ); + this._columnName = columnName; + this._dropBehaviour = dropBehaviour; + } + + @Override + protected boolean doesEqual( DropColumnDefinition another ) + { + return this._dropBehaviour.equals( another.getDropBehaviour() ) + && this._columnName.equals( another.getColumnName() ); + } + + public String getColumnName() + { + return this._columnName; + } + + public DropBehaviour getDropBehaviour() + { + return this._dropBehaviour; + } +} 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/manipulation/DropSchemaStatementImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropSchemaStatementImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropSchemaStatementImpl.java new file mode 100644 index 0000000..3aaef7b --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropSchemaStatementImpl.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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropBehaviour; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropSchemaStatement; +import org.apache.polygene.library.sql.generator.grammar.manipulation.ObjectType; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class DropSchemaStatementImpl extends DropStatementImpl<DropSchemaStatement> + implements DropSchemaStatement +{ + + private final String _schemaName; + + public DropSchemaStatementImpl( SQLProcessorAggregator processor, DropBehaviour dropBehaviour, String schemaName ) + { + this( processor, DropSchemaStatement.class, ObjectType.SCHEMA, dropBehaviour, schemaName ); + } + + protected DropSchemaStatementImpl( SQLProcessorAggregator processor, + Class<? extends DropSchemaStatement> realImplementingType, ObjectType whatToDrop, DropBehaviour dropBehaviour, + String schemaName ) + { + super( processor, realImplementingType, whatToDrop, dropBehaviour ); + Objects.requireNonNull( schemaName, "Schema name" ); + this._schemaName = schemaName; + } + + @Override + protected boolean doesEqual( DropSchemaStatement another ) + { + return this._schemaName.equals( another.getSchemaName() ) && super.doesEqual( another ); + } + + public String getSchemaName() + { + return this._schemaName; + } +} 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/manipulation/DropStatementImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropStatementImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropStatementImpl.java new file mode 100644 index 0000000..e09f573 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropStatementImpl.java @@ -0,0 +1,66 @@ +/* + * 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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.common.SchemaStatement; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropBehaviour; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropStatement; +import org.apache.polygene.library.sql.generator.grammar.manipulation.ObjectType; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class DropStatementImpl<DropStatementType extends DropStatement> extends + SQLSyntaxElementBase<SchemaStatement, DropStatementType> + implements DropStatement +{ + + private final DropBehaviour _dropBehaviour; + private final ObjectType _whatToDrop; + + protected DropStatementImpl( SQLProcessorAggregator processor, + Class<? extends DropStatementType> realImplementingType, ObjectType whatToDrop, DropBehaviour dropBehaviour ) + { + super( processor, realImplementingType ); + Objects.requireNonNull( whatToDrop, "What to drop" ); + Objects.requireNonNull( dropBehaviour, "Drop behaviour" ); + this._whatToDrop = whatToDrop; + this._dropBehaviour = dropBehaviour; + } + + protected boolean doesEqual( DropStatementType another ) + { + return this._dropBehaviour.equals( another.getDropBehaviour() ) + && this._whatToDrop.equals( another.whatToDrop() ); + } + + public DropBehaviour getDropBehaviour() + { + return this._dropBehaviour; + } + + public ObjectType whatToDrop() + { + return this._whatToDrop; + } +} 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/manipulation/DropTableConstraintDefinitionImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropTableConstraintDefinitionImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropTableConstraintDefinitionImpl.java new file mode 100644 index 0000000..3e85d7c --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropTableConstraintDefinitionImpl.java @@ -0,0 +1,73 @@ +/* + * 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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterTableAction; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropBehaviour; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropTableConstraintDefinition; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class DropTableConstraintDefinitionImpl extends + SQLSyntaxElementBase<AlterTableAction, DropTableConstraintDefinition> + implements DropTableConstraintDefinition +{ + + private final String _constraintName; + private final DropBehaviour _dropBehaviour; + + public DropTableConstraintDefinitionImpl( SQLProcessorAggregator processor, String constraintName, + DropBehaviour dropBehaviour ) + { + this( processor, DropTableConstraintDefinition.class, constraintName, dropBehaviour ); + } + + protected DropTableConstraintDefinitionImpl( SQLProcessorAggregator processor, + Class<? extends DropTableConstraintDefinition> realImplementingType, String constraintName, + DropBehaviour dropBehaviour ) + { + super( processor, realImplementingType ); + Objects.requireNonNull( constraintName, "Constraint name" ); + Objects.requireNonNull( dropBehaviour, "Drop behaviour" ); + this._constraintName = constraintName; + this._dropBehaviour = dropBehaviour; + } + + @Override + protected boolean doesEqual( DropTableConstraintDefinition another ) + { + return this._constraintName.equals( another.getConstraintName() ) + && this._dropBehaviour.equals( another.getDropBehaviour() ); + } + + public String getConstraintName() + { + return this._constraintName; + } + + public DropBehaviour getDropBehaviour() + { + return this._dropBehaviour; + } +} 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/manipulation/DropTableOrViewStatementImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropTableOrViewStatementImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropTableOrViewStatementImpl.java new file mode 100644 index 0000000..f0c0df0 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/DropTableOrViewStatementImpl.java @@ -0,0 +1,63 @@ +/* + * 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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropBehaviour; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropTableOrViewStatement; +import org.apache.polygene.library.sql.generator.grammar.manipulation.ObjectType; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class DropTableOrViewStatementImpl extends DropStatementImpl<DropTableOrViewStatement> + implements DropTableOrViewStatement +{ + + private final TableNameDirect _name; + + public DropTableOrViewStatementImpl( SQLProcessorAggregator processor, ObjectType whatToDrop, + DropBehaviour dropBehaviour, TableNameDirect name ) + { + this( processor, DropTableOrViewStatement.class, whatToDrop, dropBehaviour, name ); + } + + protected DropTableOrViewStatementImpl( SQLProcessorAggregator processor, + Class<? extends DropTableOrViewStatement> realImplementingType, ObjectType whatToDrop, + DropBehaviour dropBehaviour, TableNameDirect name ) + { + super( processor, realImplementingType, whatToDrop, dropBehaviour ); + Objects.requireNonNull( name, "Table name" ); + this._name = name; + } + + @Override + protected boolean doesEqual( DropTableOrViewStatement another ) + { + return this._name.equals( another.getTableName() ) && super.doesEqual( another ); + } + + public TableNameDirect getTableName() + { + return this._name; + } +} 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/manipulation/SetColumnDefaultImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/SetColumnDefaultImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/SetColumnDefaultImpl.java new file mode 100644 index 0000000..278f166 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/SetColumnDefaultImpl.java @@ -0,0 +1,60 @@ +/* + * 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.manipulation; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.manipulation.AlterColumnAction; +import org.apache.polygene.library.sql.generator.grammar.manipulation.SetColumnDefault; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class SetColumnDefaultImpl extends SQLSyntaxElementBase<AlterColumnAction, SetColumnDefault> + implements SetColumnDefault +{ + + private final String _default; + + public SetColumnDefaultImpl( SQLProcessorAggregator processor, String colDefault ) + { + this( processor, SetColumnDefault.class, colDefault ); + } + + protected SetColumnDefaultImpl( SQLProcessorAggregator processor, + Class<? extends SetColumnDefault> realImplementingType, String colDefault ) + { + super( processor, realImplementingType ); + Objects.requireNonNull( colDefault, "Column default" ); + this._default = colDefault; + } + + @Override + protected boolean doesEqual( SetColumnDefault another ) + { + return this._default.equals( another.getDefault() ); + } + + public String getDefault() + { + return this._default; + } +} 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/manipulation/pgsql/PgSQLDropTableOrViewStatementImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/pgsql/PgSQLDropTableOrViewStatementImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/pgsql/PgSQLDropTableOrViewStatementImpl.java new file mode 100644 index 0000000..f9e5e77 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/manipulation/pgsql/PgSQLDropTableOrViewStatementImpl.java @@ -0,0 +1,66 @@ +/* + * 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.manipulation.pgsql; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropBehaviour; +import org.apache.polygene.library.sql.generator.grammar.manipulation.DropTableOrViewStatement; +import org.apache.polygene.library.sql.generator.grammar.manipulation.ObjectType; +import org.apache.polygene.library.sql.generator.grammar.manipulation.pgsql.PgSQLDropTableOrViewStatement; +import org.apache.polygene.library.sql.generator.implementation.grammar.manipulation.DropTableOrViewStatementImpl; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class PgSQLDropTableOrViewStatementImpl extends DropTableOrViewStatementImpl + implements PgSQLDropTableOrViewStatement +{ + + private final Boolean _useIfExists; + + public PgSQLDropTableOrViewStatementImpl( SQLProcessorAggregator processor, ObjectType whatToDrop, + DropBehaviour dropBehaviour, TableNameDirect name, Boolean useIfExists ) + { + this( processor, PgSQLDropTableOrViewStatement.class, whatToDrop, dropBehaviour, name, useIfExists ); + } + + protected PgSQLDropTableOrViewStatementImpl( SQLProcessorAggregator processor, + Class<? extends PgSQLDropTableOrViewStatement> realImplementingType, ObjectType whatToDrop, + DropBehaviour dropBehaviour, TableNameDirect name, Boolean useIfExists ) + { + super( processor, realImplementingType, whatToDrop, dropBehaviour, name ); + Objects.requireNonNull( useIfExists, "Use IF EXISTS" ); + this._useIfExists = useIfExists; + } + + @Override + protected boolean doesEqual( DropTableOrViewStatement another ) + { + return super.doesEqual( another ) + && this._useIfExists.equals( ( (PgSQLDropTableOrViewStatement) another ).useIfExists() ); + } + + public Boolean useIfExists() + { + return this._useIfExists; + } +} 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/modification/ColumnSourceByQueryImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/ColumnSourceByQueryImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/ColumnSourceByQueryImpl.java new file mode 100644 index 0000000..fdd9479 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/ColumnSourceByQueryImpl.java @@ -0,0 +1,54 @@ +/* + * 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.modification; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.common.ColumnNameList; +import org.apache.polygene.library.sql.generator.grammar.modification.ColumnSourceByQuery; +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 ColumnSourceByQueryImpl extends DynamicColumnSourceImpl<ColumnSourceByQuery> + implements ColumnSourceByQuery +{ + + private final QueryExpression _query; + + public ColumnSourceByQueryImpl( SQLProcessorAggregator processor, ColumnNameList columnNames, QueryExpression query ) + { + this( processor, ColumnSourceByQuery.class, columnNames, query ); + } + + protected ColumnSourceByQueryImpl( SQLProcessorAggregator processor, + Class<? extends ColumnSourceByQuery> expressionClass, ColumnNameList columnNames, QueryExpression query ) + { + super( processor, expressionClass, columnNames ); + Objects.requireNonNull( query, "query" ); + this._query = query; + } + + public QueryExpression getQuery() + { + return this._query; + } +} 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/modification/ColumnSourceByValuesImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/ColumnSourceByValuesImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/ColumnSourceByValuesImpl.java new file mode 100644 index 0000000..f999371 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/ColumnSourceByValuesImpl.java @@ -0,0 +1,64 @@ +/* + * 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.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.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.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class ColumnSourceByValuesImpl extends DynamicColumnSourceImpl<ColumnSourceByValues> + implements ColumnSourceByValues +{ + + private final List<ValueExpression> _expressions; + + public ColumnSourceByValuesImpl( SQLProcessorAggregator processor, ColumnNameList columnNames, + List<ValueExpression> expressions ) + { + this( processor, ColumnSourceByValues.class, columnNames, expressions ); + } + + protected ColumnSourceByValuesImpl( SQLProcessorAggregator processor, + Class<? extends ColumnSourceByValues> expressionClass, ColumnNameList columnNames, + List<ValueExpression> expressions ) + { + super( processor, expressionClass, columnNames ); + Objects.requireNonNull( expressions, "expressions" ); + if( expressions.isEmpty() ) + { + throw new IllegalArgumentException( "Empty column source list not allowed." ); + } + + this._expressions = Collections.unmodifiableList( new ArrayList<ValueExpression>( expressions ) ); + } + + public List<ValueExpression> getValues() + { + return 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/modification/DeleteBySearchImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/DeleteBySearchImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/DeleteBySearchImpl.java new file mode 100644 index 0000000..21efdf7 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/DeleteBySearchImpl.java @@ -0,0 +1,72 @@ +/* + * 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.modification; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression; +import org.apache.polygene.library.sql.generator.grammar.modification.DeleteBySearch; +import org.apache.polygene.library.sql.generator.grammar.modification.DeleteStatement; +import org.apache.polygene.library.sql.generator.grammar.modification.TargetTable; +import org.apache.polygene.library.sql.generator.implementation.TypeableImpl; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class DeleteBySearchImpl extends SQLSyntaxElementBase<DeleteStatement, DeleteBySearch> + implements DeleteBySearch +{ + + private final TargetTable _targetTable; + + private final BooleanExpression _where; + + public DeleteBySearchImpl( SQLProcessorAggregator processor, TargetTable targetTable, BooleanExpression where ) + { + this( processor, DeleteBySearch.class, targetTable, where ); + } + + protected DeleteBySearchImpl( SQLProcessorAggregator processor, Class<? extends DeleteBySearch> expressionClass, + TargetTable targetTable, BooleanExpression where ) + { + super( processor, expressionClass ); + Objects.requireNonNull( targetTable, "target table" ); + this._targetTable = targetTable; + this._where = where; + } + + public TargetTable getTargetTable() + { + return this._targetTable; + } + + public BooleanExpression getWhere() + { + return this._where; + } + + @Override + protected boolean doesEqual( DeleteBySearch another ) + { + return this._targetTable.equals( another.getTargetTable() ) + && TypeableImpl.bothNullOrEquals( this._where, another.getWhere() ); + } +} 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/modification/DynamicColumnSourceImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/DynamicColumnSourceImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/DynamicColumnSourceImpl.java new file mode 100644 index 0000000..2467b35 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/DynamicColumnSourceImpl.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.modification; + +import org.apache.polygene.library.sql.generator.grammar.common.ColumnNameList; +import org.apache.polygene.library.sql.generator.grammar.modification.ColumnSource; +import org.apache.polygene.library.sql.generator.grammar.modification.DynamicColumnSource; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public abstract class DynamicColumnSourceImpl<ColumnSourceType extends DynamicColumnSource> extends + SQLSyntaxElementBase<ColumnSource, ColumnSourceType> + implements DynamicColumnSource +{ + + private final ColumnNameList _columnNames; + + protected DynamicColumnSourceImpl( SQLProcessorAggregator processor, + Class<? extends ColumnSourceType> expressionClass, ColumnNameList columnNames ) + { + super( processor, expressionClass ); + + this._columnNames = columnNames; + } + + public ColumnNameList getColumnNames() + { + return this._columnNames; + } + + @Override + protected boolean doesEqual( ColumnSourceType another ) + { + return ( this._columnNames != null && this._columnNames.equals( another.getColumnNames() ) ) + || ( this._columnNames == null && another.getColumnNames() == null ); + } +} 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/modification/InsertStatementImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/InsertStatementImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/InsertStatementImpl.java new file mode 100644 index 0000000..f7c92f1 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/InsertStatementImpl.java @@ -0,0 +1,70 @@ +/* + * 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.modification; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.modification.ColumnSource; +import org.apache.polygene.library.sql.generator.grammar.modification.InsertStatement; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class InsertStatementImpl extends SQLSyntaxElementBase<InsertStatement, InsertStatement> + implements InsertStatement +{ + + private final TableNameDirect _tableName; + private final ColumnSource _columnSource; + + public InsertStatementImpl( SQLProcessorAggregator processor, TableNameDirect tableName, ColumnSource columnSource ) + { + this( processor, InsertStatement.class, tableName, columnSource ); + } + + protected InsertStatementImpl( SQLProcessorAggregator processor, Class<? extends InsertStatement> expressionClass, + TableNameDirect tableName, ColumnSource columnSource ) + { + super( processor, expressionClass ); + Objects.requireNonNull( tableName, "tableName" ); + Objects.requireNonNull( columnSource, "column source" ); + this._tableName = tableName; + this._columnSource = columnSource; + } + + public TableNameDirect getTableName() + { + return this._tableName; + } + + public ColumnSource getColumnSource() + { + return this._columnSource; + } + + @Override + protected boolean doesEqual( InsertStatement another ) + { + return this._tableName.equals( another.getTableName() ) + && this._columnSource.equals( another.getColumnSource() ); + } +} 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/modification/SetClauseImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/SetClauseImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/SetClauseImpl.java new file mode 100644 index 0000000..25716fe --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/SetClauseImpl.java @@ -0,0 +1,70 @@ +/* + * 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.modification; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.modification.SetClause; +import org.apache.polygene.library.sql.generator.grammar.modification.UpdateSource; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class SetClauseImpl extends SQLSyntaxElementBase<SetClause, SetClause> + implements SetClause +{ + + private final String _target; + + private final UpdateSource _source; + + public SetClauseImpl( SQLProcessorAggregator processor, String updateTarget, UpdateSource updateSource ) + { + this( processor, SetClause.class, updateTarget, updateSource ); + } + + protected SetClauseImpl( SQLProcessorAggregator processor, Class<? extends SetClause> expressionClass, + String updateTarget, UpdateSource updateSource ) + { + super( processor, expressionClass ); + Objects.requireNonNull( updateTarget, "update target" ); + Objects.requireNonNull( updateSource, "source" ); + + this._target = updateTarget; + this._source = updateSource; + } + + public UpdateSource getUpdateSource() + { + return this._source; + } + + public String getUpdateTarget() + { + return this._target; + } + + @Override + protected boolean doesEqual( SetClause another ) + { + return this._target.equals( another.getUpdateTarget() ) && this._source.equals( another.getUpdateSource() ); + } +} 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/modification/TargetTableImpl.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/TargetTableImpl.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/TargetTableImpl.java new file mode 100644 index 0000000..af8a119 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/modification/TargetTableImpl.java @@ -0,0 +1,72 @@ +/* + * 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.modification; + +import java.util.Objects; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; +import org.apache.polygene.library.sql.generator.grammar.modification.TargetTable; +import org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase; +import org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator; + +/** + * @author Stanislav Muhametsin + */ +public class TargetTableImpl extends SQLSyntaxElementBase<TargetTable, TargetTable> + implements TargetTable +{ + + private Boolean _isOnly; + + private TableNameDirect _tableName; + + public TargetTableImpl( SQLProcessorAggregator processor, Boolean isOnly, TableNameDirect tableName ) + { + this( processor, TargetTable.class, isOnly, tableName ); + } + + protected TargetTableImpl( SQLProcessorAggregator processor, Class<? extends TargetTable> expressionClass, + Boolean isOnly, TableNameDirect tableName ) + { + super( processor, expressionClass ); + Objects.requireNonNull( tableName, "table name" ); + if( isOnly == null ) + { + isOnly = false; + } + this._tableName = tableName; + this._isOnly = isOnly; + } + + public Boolean isOnly() + { + return this._isOnly; + } + + public TableNameDirect getTableName() + { + return this._tableName; + } + + @Override + protected boolean doesEqual( TargetTable another ) + { + return this._tableName.equals( another.getTableName() ) && this._isOnly.equals( another.isOnly() ); + } +}
