Enum in Java

Source: Internet
Author: User

1. Enum Class

public enum Containerpropertyconstants {    retailer ("retailer"),    lined ("islined"),    BAGGING ("BAGGING"),    MISSING ("MISSING"),    Movable ("movable"),    reservable ("reservable"),    contained_delivery_tote ("Hascontainerdeliverytote"),    damaged ("isdamaged"),    DIRTY ("IsDirty"),    Tainted ("istainted"),    contained_stock ("Hascontainedstock"),    UNKNOWN ("UNKNOWN") ;        private String value;    Private containerpropertyconstants (String value) {        this.value = value;    }        Public String GetValue () {        return value;    }    @Override public    String toString () {        return this.getvalue ();    }    public static containerpropertyconstants Getenum (String propertykey) {for        (containerpropertyconstants v:values ( ) {            if (V.getvalue (). Equals (Propertykey.trim ())) {                 return v;            }        }        return UNKNOWN;}    }

2. Use Enum Class

    Private Binattributes getbinattributes (Map<propertykey, propertyvalue> properties, Binattributes.builder                 Builder) {Properties.foreach (k, v) {switch (Containerpropertyconstants.getenum (k.tostring ())) {                Case Lined:break;                    Case MOVABLE:builder.setAccessibleToPhoenix (boolean.valueof (V.getpropertyvalue ()));                Break                Case Reservable:break;                Case Contained_delivery_tote:break;                    Case DAMAGED:builder.setDamaged (boolean.valueof (V.getpropertyvalue ()));                Break                    Case DIRTY:builder.setContaminated (boolean.valueof (V.getpropertyvalue ()));                Break                    Case TAINTED:builder.setTainted (boolean.valueof (V.getpropertyvalue ()));                Break Case Contained_stOck:break; Case Unknown:throw New IllegalArgumentException (' Phoenix container property [' + K + '] not recognised                .");                    Default:logger.info ("Currently cannot handle container property [{}]", K);            Break                }        });    return Builder.build (); }

Enum in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.