diff --git a/src/main/java/ua/net/uid/utils/db/annotation/Column.java b/src/main/java/ua/net/uid/utils/db/annotation/Column.java new file mode 100644 index 0000000..d7ca7ed --- /dev/null +++ b/src/main/java/ua/net/uid/utils/db/annotation/Column.java @@ -0,0 +1,30 @@ +/* + * Copyright 2020 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ua.net.uid.utils.db.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.FIELD) +public @interface Column { + + String name() default ""; + boolean primary() default false; + boolean auto() default false; +} diff --git a/src/main/java/ua/net/uid/utils/db/annotation/Columns.java b/src/main/java/ua/net/uid/utils/db/annotation/Columns.java new file mode 100644 index 0000000..c9a20e7 --- /dev/null +++ b/src/main/java/ua/net/uid/utils/db/annotation/Columns.java @@ -0,0 +1,26 @@ +/* + * Copyright 2020 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ua.net.uid.utils.db.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.FIELD) +public @interface Columns { +} diff --git a/src/main/java/ua/net/uid/utils/db/dao/Processor.java b/src/main/java/ua/net/uid/utils/db/dao/Processor.java new file mode 100644 index 0000000..0e5bc0a --- /dev/null +++ b/src/main/java/ua/net/uid/utils/db/dao/Processor.java @@ -0,0 +1,48 @@ +/* + * Copyright 2020 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ua.net.uid.utils.db.dao; + +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; + +/** + * + * @author nightfall + */ +@SupportedSourceVersion(SourceVersion.RELEASE_8) +@SupportedAnnotationTypes({ + "ua.net.uid.utils.db.annotation.Column", + "ua.net.uid.utils.db.annotation.Columns" + /* + "ua.net.uid.utils.orm.annotations.Table", + "ua.net.uid.utils.orm.annotations.Select", + "ua.net.uid.utils.orm.annotations.Update", + */ +}) +public class Processor extends AbstractProcessor { + @Override + public boolean process(Set annotations, RoundEnvironment roundEnvironment) { + if (annotations.isEmpty()) return false; + + + return true; + } +} diff --git a/src/test/java/ua/net/uid/utils/db/dao/DAOAbstractTest.java b/src/test/java/ua/net/uid/utils/db/dao/DAOAbstractTest.java index 9e64e47..8ad809e 100644 --- a/src/test/java/ua/net/uid/utils/db/dao/DAOAbstractTest.java +++ b/src/test/java/ua/net/uid/utils/db/dao/DAOAbstractTest.java @@ -255,7 +255,7 @@ @Override public boolean insert(Item item) throws SQLException { - Processor processor = new QueryBuilder().append("INSERT INTO ").append(getTableName()).append( + ua.net.uid.utils.db.Processor processor = new QueryBuilder().append("INSERT INTO ").append(getTableName()).append( " (title, value, disabled, modified) VALUES (?,?,?,?)" , item.getTitle(), item.getValue(), item.isDisabled(), item.getModified() ).on(getSession());