io.github.jeddict.jsonb.generator.compiler.VisibilitySnippet Maven / Gradle / Ivy
/**
* Copyright 2013-2022 the original author or authors from the Jeddict project (https://jeddict.github.io/).
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.github.jeddict.jsonb.generator.compiler;
import static io.github.jeddict.jcode.JSONBConstants.JSONB_VISIBILITY;
import static io.github.jeddict.jcode.JSONBConstants.JSONB_VISIBILITY_FQN;
import io.github.jeddict.jpa.spec.extend.ReferenceClass;
import io.github.jeddict.orm.generator.compiler.InvalidDataException;
import io.github.jeddict.orm.generator.compiler.Snippet;
import io.github.jeddict.orm.generator.util.ClassHelper;
import static io.github.jeddict.orm.generator.util.ORMConverterUtil.AT;
import static io.github.jeddict.orm.generator.util.ORMConverterUtil.CLOSE_PARANTHESES;
import static io.github.jeddict.orm.generator.util.ORMConverterUtil.OPEN_PARANTHESES;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class VisibilitySnippet implements Snippet {
private final ClassHelper type;
public VisibilitySnippet(ReferenceClass referenceClass) {
this.type = new ClassHelper(referenceClass.getName());
}
@Override
public String getSnippet() throws InvalidDataException {
StringBuilder builder = new StringBuilder(AT);
builder.append(JSONB_VISIBILITY)
.append(OPEN_PARANTHESES)
.append(type.getClassNameWithClassSuffix())
.append(CLOSE_PARANTHESES);
return builder.toString();
}
@Override
public Collection getImportSnippets() throws InvalidDataException {
Set imports = new HashSet<>();
imports.add(JSONB_VISIBILITY_FQN);
imports.add(type.getFQClassName());
return imports;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy