8273140: Replace usages of Enum.class.getEnumConstants() with Enum.values() where possible

Reviewed-by: tschatzl
This commit is contained in:
Sergey Tsypanov 2021-09-02 08:10:40 +00:00 committed by Thomas Schatzl
parent 857a930bde
commit 152e66923d
4 changed files with 11 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -211,7 +211,7 @@ public final class AttributeValues implements Cloneable {
}
public static final int MASK_ALL =
getMask(EAttribute.class.getEnumConstants());
getMask(EAttribute.values());
public void unsetDefault() {
defined &= nondefault;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -75,7 +75,7 @@ public enum EAttribute {
att = ta;
}
/* package */ static final EAttribute[] atts = EAttribute.class.getEnumConstants();
/* package */ static final EAttribute[] atts = EAttribute.values();
public static EAttribute forAttribute(Attribute ta) {
for (EAttribute ea: atts) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -206,7 +206,7 @@ public enum JDBCType implements SQLType {
* The Integer value for the JDBCType. It maps to a value in
* {@code Types.java}
*/
private Integer type;
private final Integer type;
/**
* Constructor to specify the data type value from {@code Types) for
@ -251,8 +251,8 @@ public enum JDBCType implements SQLType {
* @see Types
*/
public static JDBCType valueOf(int type) {
for( JDBCType sqlType : JDBCType.class.getEnumConstants()) {
if(type == sqlType.type)
for (JDBCType sqlType : JDBCType.values()) {
if (type == sqlType.type)
return sqlType;
}
throw new IllegalArgumentException("Type:" + type + " is not a valid "

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -169,7 +169,7 @@ enum AccessModifier {
};
public static AccessModifier getRandomAccessModifier(Random rnd) {
AccessModifier[] a = AccessModifier.class.getEnumConstants();
AccessModifier[] a = AccessModifier.values();
return a[rnd.nextInt(a.length)];
}
}
@ -198,8 +198,6 @@ enum Type {
}
}
;
public String init(Random rnd) {
switch (this) {
case LONG:
@ -222,7 +220,7 @@ enum Type {
}
public static Type getRandomType(Random rnd) {
Type[] a = Type.class.getEnumConstants();
Type[] a = Type.values();
return a[rnd.nextInt(a.length)];
}
}