Enum ordinal - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Enum ordinal method.

This code example shows how to use the following methods:ordinal
	 * @see org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#determineDatabaseDialectClass(org.springframework.orm.jpa.vendor.Database) 
	 */ 
	@Override 
	protected Class<?> determineDatabaseDialectClass(Database database) { 
 
		if (Database.HSQL.equals(database)) { 
			return CustomHsqlDialect.class; 
		} 
 
		return super.determineDatabaseDialectClass(database); 
	} 
 
	public static class CustomHsqlDialect extends HSQLDialect { 
 
		public CustomHsqlDialect() { 
			registerColumnType(Types.BOOLEAN, "boolean"); 
			registerHibernateType(Types.BOOLEAN, "boolean"); 
		} 
	} 
} 

6
CodeRank
This code example shows how to use the following methods:ordinal
    /* 
     * This method is based on the method of the same name in Stopwatch.java in 
     * Google Guava 14.0.1, where it was defined with private visibility. 
     */ 
    static String abbreviate(TimeUnit unit) {
        switch (unit) {
        case NANOSECONDS:
            return "ns"; 
        case MICROSECONDS:
            return "\u03bcs"; // μs 
        case MILLISECONDS:
            return "ms"; 
        case SECONDS:
            return "s"; 
        case MINUTES:
            return "m"; 
        case HOURS:
            return "h"; 
        case DAYS:
            return "d"; 
6
CodeRank
This code example shows how to use the following methods:ordinal
import javax.lang.model.util.SimpleTypeVisitor6;
 
/** 
 * Utilities for handling types in annotation processors 
 */ 
final class Util { 
  private Util() { 
  } 
 
  public static PackageElement getPackage(Element type) {
    while (type.getKind() != ElementKind.PACKAGE) {
      type = type.getEnclosingElement();
    } 
    return (PackageElement) type;
  } 
 
  /** 
   * Returns the supertype, or {@code null} if the supertype is a platform 
   * class. This is intended for annotation processors that assume platform 
   * classes will never be annotated with application annotations. 
5
CodeRank
This code example shows how to use the following methods:ordinal
This code example shows how to use the following methods:ordinal
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; 
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetQuotaRequest; 
 
@InterfaceAudience.Public 
@InterfaceStability.Evolving 
public abstract class QuotaSettings { 
  private final String userName;
  private final String namespace;
  private final TableName tableName;
 
  protected QuotaSettings(final String userName, final TableName tableName,
      final String namespace) {
    this.userName = userName;
    this.namespace = namespace;
    this.tableName = tableName;
  } 
 
  public abstract QuotaType getQuotaType(); 
 
  public String getUserName() {
5
CodeRank
This code example shows how to use the following methods:ordinal
   public Optional<HostAndPort> getProxy() {
      if (host == null)
         return Optional.absent();
      Integer port = this.port;
      if (port == null) {
         switch (type) {
         case HTTP:
            port = 80;
            break; 
         case SOCKS:
            port = 1080;
            break; 
         default: 
            throw new IllegalArgumentException(type + " not supported");
         } 
      } 
      return Optional.of(HostAndPort.fromParts(host, port));
   } 
 
   @Override 
5
CodeRank
This code example shows how to use the following methods:ordinal
 *     limiter.consume(); 
 *   } 
 */ 
@InterfaceAudience.Private 
@InterfaceStability.Evolving 
public class RateLimiter { 
  private long tunit = 1000;           // Timeunit factor for translating to ms.
  private long limit = Long.MAX_VALUE; // The max value available resource units can be refilled to.
  private long avail = Long.MAX_VALUE; // Currently available resource units
 
  public RateLimiter() { 
  } 
 
  /** 
   * Set the RateLimiter max available resources and refill period. 
   * @param limit The max value available resource units can be refilled to. 
   * @param timeUnit Timeunit factor for translating to ms. 
   */ 
  public void set(final long limit, final TimeUnit timeUnit) {
    switch (timeUnit) {
5
CodeRank
This code example shows how to use the following methods:ordinal
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.type.TypeMirror;
 
class TypeSummary implements Renderable { 
 
  private String summary;
 
  public TypeSummary(RenderableTypes renderables, TypeElement element) {
    StringBuilder builder = new StringBuilder();
 
    appendTypeSignature(builder, element);
 
    Set<String> nestedTypes = new TreeSet<>();
    Set<String> contained = new TreeSet<>();
    // Ordering matters for enum constants. 
    Set<String> enumValues = new LinkedHashSet<>();
 
    // Collect the enclosed elements, keeping enclosed types separately. 
5
CodeRank
This code example shows how to use the following methods:equals, ordinal
public class ValidationTool { 
  /** 
   * A JavaFileManager that writes the class outputs into a jar file or a 
   * directory. 
   */ 
  static class JarOrDirectoryOutputFileManager extends ForwardingJavaFileManager<JavaFileManager> {
    private final List<MemoryJavaFileObject> toOutput = new ArrayList<MemoryJavaFileObject>();
    private final File output;
 
    JarOrDirectoryOutputFileManager(File output, JavaFileManager fileManager) {
      super(fileManager);
      this.output = output;
    } 
 
    @Override 
    public void close() throws IOException {
      if (output.isDirectory()) {
        writeToDirectory(); 
      } else { 
        writeToJar(); 

5
CodeRank
This code example shows how to use the following methods:ordinal
 * <p/> 
 * By default we publish count (number of times the timer was executed), totalTime, and 
 * the counts and times for the following buckets: 0ms, 100ms, 200ms, 500ms, 
 * 1000ms 2000ms, 3000ms, 5000ms 
 */ 
public final class BucketConfig { 
 
    /** 
     * Helper class for constructing BucketConfigs. 
     */ 
    public static class Builder { 
        private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        private long[] buckets = null;
 
        /** 
         * Sets the timeUnit for the buckets. 
         */ 
        public Builder withTimeUnit(TimeUnit timeUnit) {
            this.timeUnit = Preconditions.checkNotNull(timeUnit);
            return this;
5
CodeRank
ordinal Method Overview
Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).
See Code Examples for other Java 8 Enum Methods: