add some Javadoc, fix warning, and remove some minor junk

This commit is contained in:
Gavin King 2022-02-02 22:11:25 +01:00
parent c41c5c7472
commit 11f784e23b
21 changed files with 29 additions and 38 deletions

View File

@ -17,7 +17,7 @@ package org.hibernate.boot;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class CacheRegionDefinition { public class CacheRegionDefinition {
public static enum CacheRegionType { public enum CacheRegionType {
ENTITY, ENTITY,
COLLECTION, COLLECTION,
QUERY QUERY

View File

@ -9,6 +9,8 @@ package org.hibernate.boot;
import org.hibernate.boot.jaxb.Origin; import org.hibernate.boot.jaxb.Origin;
/** /**
* Indicates a problem parsing the mapping document at a given {@link Origin}.
*
* @author Brett Meyer * @author Brett Meyer
*/ */
public class InvalidMappingException extends org.hibernate.InvalidMappingException { public class InvalidMappingException extends org.hibernate.InvalidMappingException {

View File

@ -9,6 +9,8 @@ package org.hibernate.boot;
import org.hibernate.boot.jaxb.Origin; import org.hibernate.boot.jaxb.Origin;
/** /**
* Indicates that a mapping document could not be found at a given {@link Origin}.
*
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class MappingNotFoundException extends MappingException { public class MappingNotFoundException extends MappingException {

View File

@ -10,7 +10,7 @@ import org.hibernate.HibernateException;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
/** /**
* Defines the possible values for "hbm2ddl_auto" * Defines the possible values for {@value AvailableSettings#HBM2DDL_AUTO}.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -31,7 +31,6 @@ import org.hibernate.resource.jdbc.spi.StatementInspector;
* *
* @since 5.0 * @since 5.0
*/ */
@SuppressWarnings("UnusedReturnValue")
public interface SessionFactoryBuilder { public interface SessionFactoryBuilder {
/** /**
* Specifies a Bean Validation {@link jakarta.validation.ValidatorFactory}. * Specifies a Bean Validation {@link jakarta.validation.ValidatorFactory}.

View File

@ -19,7 +19,6 @@ public class UnsupportedOrmXsdVersionException extends MappingException {
this.requestedVersion = requestedVersion; this.requestedVersion = requestedVersion;
} }
@SuppressWarnings("UnusedDeclaration")
public String getRequestedVersion() { public String getRequestedVersion() {
return requestedVersion; return requestedVersion;
} }

View File

@ -34,8 +34,8 @@ public class ConfigLoader {
private final BootstrapServiceRegistry bootstrapServiceRegistry; private final BootstrapServiceRegistry bootstrapServiceRegistry;
private ValueHolder<JaxbCfgProcessor> jaxbProcessorHolder = new ValueHolder<>( private final ValueHolder<JaxbCfgProcessor> jaxbProcessorHolder = new ValueHolder<>(
new ValueHolder.DeferredInitializer<JaxbCfgProcessor>() { new ValueHolder.DeferredInitializer<>() {
@Override @Override
public JaxbCfgProcessor initialize() { public JaxbCfgProcessor initialize() {
return new JaxbCfgProcessor( bootstrapServiceRegistry.getService( ClassLoaderService.class ) ); return new JaxbCfgProcessor( bootstrapServiceRegistry.getService( ClassLoaderService.class ) );

View File

@ -87,14 +87,12 @@ public class JaxbCfgProcessor {
return staxFactory; return staxFactory;
} }
@SuppressWarnings( { "UnnecessaryLocalVariable" })
private XMLInputFactory buildStaxFactory() { private XMLInputFactory buildStaxFactory() {
XMLInputFactory staxFactory = XMLInputFactory.newInstance(); XMLInputFactory staxFactory = XMLInputFactory.newInstance();
staxFactory.setXMLResolver( xmlResourceResolver ); staxFactory.setXMLResolver( xmlResourceResolver );
return staxFactory; return staxFactory;
} }
@SuppressWarnings( { "unchecked" })
private JaxbCfgHibernateConfiguration unmarshal(XMLEventReader staxEventReader, final Origin origin) { private JaxbCfgHibernateConfiguration unmarshal(XMLEventReader staxEventReader, final Origin origin) {
XMLEvent event; XMLEvent event;
try { try {
@ -165,10 +163,7 @@ public class JaxbCfgProcessor {
SchemaFactory schemaFactory = SchemaFactory.newInstance( schemaLanguage ); SchemaFactory schemaFactory = SchemaFactory.newInstance( schemaLanguage );
return schemaFactory.newSchema( source ); return schemaFactory.newSchema( source );
} }
catch ( SAXException e ) { catch ( SAXException | IOException e ) {
throw new XsdException( "Unable to load schema [" + schemaName + "]", e, schemaName );
}
catch ( IOException e ) {
throw new XsdException( "Unable to load schema [" + schemaName + "]", e, schemaName ); throw new XsdException( "Unable to load schema [" + schemaName + "]", e, schemaName );
} }
finally { finally {

View File

@ -19,7 +19,7 @@ import org.hibernate.internal.util.config.ConfigurationException;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class MappingReference { public class MappingReference {
public static enum Type { public enum Type {
RESOURCE, RESOURCE,
CLASS, CLASS,
FILE, FILE,

View File

@ -45,8 +45,6 @@ import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.jandex.IndexView; import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;
/** /**
* @author Andrea Boriero * @author Andrea Boriero
*/ */
@ -78,7 +76,7 @@ public class BootstrapContextImpl implements BootstrapContext {
private ArrayList<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList; private ArrayList<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList;
private HashMap<Class<?>, ConverterDescriptor> attributeConverterDescriptorMap; private HashMap<Class<?>, ConverterDescriptor> attributeConverterDescriptorMap;
private ArrayList<CacheRegionDefinition> cacheRegionDefinitions; private ArrayList<CacheRegionDefinition> cacheRegionDefinitions;
private ManagedTypeRepresentationResolver representationStrategySelector; private final ManagedTypeRepresentationResolver representationStrategySelector;
public BootstrapContextImpl( public BootstrapContextImpl(
StandardServiceRegistry serviceRegistry, StandardServiceRegistry serviceRegistry,

View File

@ -105,7 +105,7 @@ public class IdGeneratorInterpreterImpl implements IdGeneratorStrategyInterprete
return IncrementGenerator.class.getName(); return IncrementGenerator.class.getName();
} }
final Class javaType = context.getIdType(); final Class<?> javaType = context.getIdType();
if ( UUID.class.isAssignableFrom( javaType ) ) { if ( UUID.class.isAssignableFrom( javaType ) ) {
return UUIDGenerator.class.getName(); return UUIDGenerator.class.getName();
} }

View File

@ -43,7 +43,7 @@ import static org.hibernate.procedure.spi.NamedCallableQueryMemento.ParameterMem
public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefinition { public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefinition {
private final String registeredName; private final String registeredName;
private final String procedureName; private final String procedureName;
private final Class[] resultClasses; private final Class<?>[] resultClasses;
private final String[] resultSetMappings; private final String[] resultSetMappings;
private final ParameterDefinitions parameterDefinitions; private final ParameterDefinitions parameterDefinitions;
private final Map<String, Object> hints; private final Map<String, Object> hints;
@ -205,7 +205,7 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
private final Integer position; private final Integer position;
private final String name; private final String name;
private final ParameterMode parameterMode; private final ParameterMode parameterMode;
private final Class type; private final Class<?> type;
static ParameterDefinition from( static ParameterDefinition from(
ParameterStrategy parameterStrategy, ParameterStrategy parameterStrategy,
@ -234,7 +234,6 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
this.type = annotation.type(); this.type = annotation.type();
} }
@SuppressWarnings("UnnecessaryUnboxing")
public ParameterMemento toMemento(SessionFactoryImplementor sessionFactory) { public ParameterMemento toMemento(SessionFactoryImplementor sessionFactory) {
// todo (6.0): figure out how to handle this // todo (6.0): figure out how to handle this
// final boolean initialPassNullSetting = explicitPassNullSetting != null // final boolean initialPassNullSetting = explicitPassNullSetting != null

View File

@ -23,7 +23,6 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@SuppressWarnings("deprecation")
public class DialectResolverInitiator implements StandardServiceInitiator<DialectResolver> { public class DialectResolverInitiator implements StandardServiceInitiator<DialectResolver> {
/** /**
* Singleton access * Singleton access
@ -55,9 +54,8 @@ public class DialectResolverInitiator implements StandardServiceInitiator<Dialec
if ( StringHelper.isNotEmpty( resolverImplNames ) ) { if ( StringHelper.isNotEmpty( resolverImplNames ) ) {
for ( String resolverImplName : StringHelper.split( ", \n\r\f\t", resolverImplNames ) ) { for ( String resolverImplName : StringHelper.split( ", \n\r\f\t", resolverImplNames ) ) {
try { try {
resolverSet.addResolver( DialectResolver dialectResolver = (DialectResolver) classLoaderService.classForName(resolverImplName).newInstance();
(DialectResolver) classLoaderService.classForName( resolverImplName ).newInstance() resolverSet.addResolver( dialectResolver );
);
} }
catch (HibernateException e) { catch (HibernateException e) {
throw e; throw e;

View File

@ -27,7 +27,7 @@ import org.hibernate.internal.CoreMessageLogger;
public class DialectResolverSet implements DialectResolver { public class DialectResolverSet implements DialectResolver {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( DialectResolverSet.class ); private static final CoreMessageLogger LOG = CoreLogging.messageLogger( DialectResolverSet.class );
private List<DialectResolver> resolvers; private final List<DialectResolver> resolvers;
public DialectResolverSet() { public DialectResolverSet() {
this( new ArrayList<>() ); this( new ArrayList<>() );

View File

@ -21,7 +21,7 @@ public class BasicDialectResolver implements DialectResolver {
private final int majorVersionToMatch; private final int majorVersionToMatch;
private final int minorVersionToMatch; private final int minorVersionToMatch;
private final Class dialectClass; private final Class<?> dialectClass;
/** /**
* Constructs a BasicDialectResolver * Constructs a BasicDialectResolver

View File

@ -12,7 +12,7 @@ import java.util.Iterator;
* @author Gavin King * @author Gavin King
*/ */
public final class SingletonIterator<T> implements Iterator<T> { public final class SingletonIterator<T> implements Iterator<T> {
private T value; private final T value;
private boolean hasNext = true; private boolean hasNext = true;
public boolean hasNext() { public boolean hasNext() {

View File

@ -34,14 +34,14 @@ public final class StandardStack<T> implements Stack<T> {
@Override @Override
public void push(T newCurrent) { public void push(T newCurrent) {
Object toStore = newCurrent; T toStore = newCurrent;
if ( newCurrent == null ) { if ( newCurrent == null ) {
toStore = NULL_TOKEN; toStore = (T) NULL_TOKEN;
} }
stackInstanceExpected().addFirst( toStore ); stackInstanceExpected().addFirst( toStore );
} }
private Deque stackInstanceExpected() { private Deque<T> stackInstanceExpected() {
if ( internalStack == null ) { if ( internalStack == null ) {
//"7" picked to use 8, but skipping the odd initialCapacity method //"7" picked to use 8, but skipping the odd initialCapacity method
internalStack = new ArrayDeque<>( 7 ); internalStack = new ArrayDeque<>( 7 );
@ -108,10 +108,9 @@ public final class StandardStack<T> implements Stack<T> {
if ( internalStack == null ) { if ( internalStack == null ) {
return null; return null;
} }
final Iterator<T> iterator = internalStack.iterator(); for (T t : internalStack) {
while ( iterator.hasNext() ) { final X result = function.apply(t);
final X result = function.apply( iterator.next() ); if (result != null) {
if ( result != null ) {
return result; return result;
} }
} }

View File

@ -23,7 +23,7 @@ public class ComparableComparator<T extends Comparable> implements Comparator<T>
return INSTANCE; return INSTANCE;
} }
@SuppressWarnings({ "unchecked" }) @SuppressWarnings("unchecked")
public int compare(Comparable one, Comparable another) { public int compare(Comparable one, Comparable another) {
return one.compareTo( another ); return one.compareTo( another );
} }

View File

@ -87,7 +87,7 @@ public class DTDEntityResolver implements EntityResolver, Serializable {
InputStream dtdStream = resolveInHibernateNamespace( path ); InputStream dtdStream = resolveInHibernateNamespace( path );
if ( dtdStream == null ) { if ( dtdStream == null ) {
LOG.debugf( "Unable to locate [%s] on classpath", systemId ); LOG.debugf( "Unable to locate [%s] on classpath", systemId );
if ( systemId.substring( namespace.length() ).indexOf( "2.0" ) > -1 ) { if ( systemId.substring( namespace.length() ).contains("2.0") ) {
LOG.usingOldDtd(); LOG.usingOldDtd();
} }
} }

View File

@ -15,7 +15,7 @@ package org.hibernate.tool.schema;
public enum Action { public enum Action {
/** /**
* No action will be performed. Valid in JPA; compatible with Hibernate's * No action will be performed. Valid in JPA; compatible with Hibernate's
* hbm2ddl action of the same name.. * hbm2ddl action of the same name.
*/ */
NONE( "none" ), NONE( "none" ),
/** /**

View File

@ -232,7 +232,7 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
javaTypeRegistry.resolveDescriptor( javaTypeRegistry.resolveDescriptor(
basicType.getJavaType(), basicType.getJavaType(),
() -> basicType.getJavaTypeDescriptor() basicType::getJavaTypeDescriptor
); );
jdbcToHibernateTypeContributionMap.computeIfAbsent( jdbcToHibernateTypeContributionMap.computeIfAbsent(