com.blazebit.persistence.parser.ListIndexAttribute Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014 - 2024 Blazebit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.blazebit.persistence.parser;
import jakarta.persistence.metamodel.ListAttribute;
import jakarta.persistence.metamodel.ManagedType;
import jakarta.persistence.metamodel.PluralAttribute;
import jakarta.persistence.metamodel.SingularAttribute;
import jakarta.persistence.metamodel.Type;
import java.lang.reflect.Member;
/**
* @author Christian Beikov
* @since 1.2.0
*/
public class ListIndexAttribute implements SingularAttribute, QualifiedAttribute {
private static final Type INDEX_TYPE = new Type() {
@Override
public PersistenceType getPersistenceType() {
return PersistenceType.BASIC;
}
@Override
public Class getJavaType() {
return Integer.class;
}
};
private final ListAttribute attribute;
public ListIndexAttribute(ListAttribute attribute) {
this.attribute = attribute;
}
@Override
public PluralAttribute getPluralAttribute() {
return attribute;
}
@Override
public String getQualificationExpression() {
return "INDEX";
}
@Override
public String getName() {
return attribute.getName() + "_index";
}
@Override
public PersistentAttributeType getPersistentAttributeType() {
return PersistentAttributeType.BASIC;
}
@Override
public ManagedType getDeclaringType() {
return null;
}
@Override
public Class getJavaType() {
return Integer.class;
}
@Override
public Member getJavaMember() {
return null;
}
@Override
public boolean isAssociation() {
return false;
}
@Override
public boolean isCollection() {
return false;
}
@Override
public boolean isId() {
return false;
}
@Override
public boolean isVersion() {
return false;
}
@Override
public boolean isOptional() {
return false;
}
@Override
public Type getType() {
return INDEX_TYPE;
}
@Override
public BindableType getBindableType() {
return BindableType.SINGULAR_ATTRIBUTE;
}
@Override
public Class getBindableJavaType() {
return Integer.class;
}
}