< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java

Print this page


   1 /*
   2  * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 package com.sun.org.apache.bcel.internal.generic;
  21 
  22 import java.util.ArrayList;
  23 import java.util.List;
  24 import java.util.Objects;
  25 
  26 import com.sun.org.apache.bcel.internal.Const;
  27 import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry;
  28 import com.sun.org.apache.bcel.internal.classfile.Annotations;
  29 import com.sun.org.apache.bcel.internal.classfile.Attribute;
  30 import com.sun.org.apache.bcel.internal.classfile.Constant;
  31 import com.sun.org.apache.bcel.internal.classfile.ConstantObject;
  32 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
  33 import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
  34 import com.sun.org.apache.bcel.internal.classfile.Field;
  35 import com.sun.org.apache.bcel.internal.classfile.Utility;
  36 import com.sun.org.apache.bcel.internal.util.BCELComparator;
  37 
  38 /**
  39  * Template class for building up a field.  The only extraordinary thing
  40  * one can do is to add a constant value attribute to a field (which must of
  41  * course be compatible with to the declared type).
  42  *
  43  * @version $Id$
  44  * @see Field
  45  * @LastModified: Jun 2019
  46  */
  47 public class FieldGen extends FieldGenOrMethodGen {
  48 
  49     private Object value = null;
  50     private static BCELComparator bcelComparator = new BCELComparator() {
  51 
  52         @Override
  53         public boolean equals( final Object o1, final Object o2 ) {
  54             final FieldGen THIS = (FieldGen) o1;
  55             final FieldGen THAT = (FieldGen) o2;
  56             return Objects.equals(THIS.getName(), THAT.getName())
  57                     && Objects.equals(THIS.getSignature(), THAT.getSignature());
  58         }
  59 
  60 
  61         @Override
  62         public int hashCode( final Object o ) {
  63             final FieldGen THIS = (FieldGen) o;
  64             return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
  65         }


   1 /*
   2  * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 package com.sun.org.apache.bcel.internal.generic;
  21 
  22 import java.util.ArrayList;
  23 import java.util.List;
  24 import java.util.Objects;
  25 
  26 import com.sun.org.apache.bcel.internal.Const;
  27 import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry;
  28 import com.sun.org.apache.bcel.internal.classfile.Annotations;
  29 import com.sun.org.apache.bcel.internal.classfile.Attribute;
  30 import com.sun.org.apache.bcel.internal.classfile.Constant;
  31 import com.sun.org.apache.bcel.internal.classfile.ConstantObject;
  32 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
  33 import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
  34 import com.sun.org.apache.bcel.internal.classfile.Field;
  35 import com.sun.org.apache.bcel.internal.classfile.Utility;
  36 import com.sun.org.apache.bcel.internal.util.BCELComparator;
  37 
  38 /**
  39  * Template class for building up a field.  The only extraordinary thing
  40  * one can do is to add a constant value attribute to a field (which must of
  41  * course be compatible with to the declared type).
  42  *

  43  * @see Field
  44  * @LastModified: Jan 2020
  45  */
  46 public class FieldGen extends FieldGenOrMethodGen {
  47 
  48     private Object value = null;
  49     private static BCELComparator bcelComparator = new BCELComparator() {
  50 
  51         @Override
  52         public boolean equals( final Object o1, final Object o2 ) {
  53             final FieldGen THIS = (FieldGen) o1;
  54             final FieldGen THAT = (FieldGen) o2;
  55             return Objects.equals(THIS.getName(), THAT.getName())
  56                     && Objects.equals(THIS.getSignature(), THAT.getSignature());
  57         }
  58 
  59 
  60         @Override
  61         public int hashCode( final Object o ) {
  62             final FieldGen THIS = (FieldGen) o;
  63             return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
  64         }


< prev index next >