⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hobby.java

📁 jboss规则引擎
💻 JAVA
字号:
/*
 * Copyright 2005 JBoss Inc
 * 
 * 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 org.drools.examples.manners;

public class Hobby {
    public static final String   stringH1     = "h1";
    public static final String   stringH2     = "h2";
    public static final String   stringH3     = "h3";
    public static final String   stringH4     = "h4";
    public static final String   stringH5     = "h5";

    public static final String[] hobbyStrings = new String[]{Hobby.stringH1, Hobby.stringH2, Hobby.stringH3, Hobby.stringH4, Hobby.stringH5};

    public static final Hobby    H1           = new Hobby( 1 );
    public static final Hobby    H2           = new Hobby( 2 );
    public static final Hobby    H3           = new Hobby( 3 );
    public static final Hobby    H4           = new Hobby( 4 );
    public static final Hobby    H5           = new Hobby( 5 );

    private final String         hobbyStr;
    private final int            hobbyIndex;

    private Hobby(final int hobby) {
        this.hobbyIndex = hobby - 1;
        this.hobbyStr = Hobby.hobbyStrings[this.hobbyIndex];
    }

    public final String getHobby() {
        return this.hobbyStr;
    }

    public final static Hobby resolve(final String hobby) {
        if ( Hobby.stringH1.equals( hobby ) ) {
            return Hobby.H1;
        } else if ( Hobby.stringH2.equals( hobby ) ) {
            return Hobby.H2;
        } else if ( Hobby.stringH3.equals( hobby ) ) {
            return Hobby.H3;
        } else if ( Hobby.stringH4.equals( hobby ) ) {
            return Hobby.H4;
        } else if ( Hobby.stringH5.equals( hobby ) ) {
            return Hobby.H5;
        } else {
            throw new RuntimeException( "Hobby '" + hobby + "' does not exist for Hobby Enum" );
        }
    }

    public final String toString() {
        return getHobby();
    }

    public final boolean equals(final Object object) {
        return (this == object);
    }

    public final int hashCode() {
        return this.hobbyIndex;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -