ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/value/ValueEnumBase.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/value/ValueEnumBase.java
Status
scanned
Type
file
Name
ValueEnumBase.java
Extension
.java
Programming language
Java
Mime type
text/x-java
File type
Java source, ASCII text
Tag

      
    
Rootfs path

      
    
Size
3249 (3.2 KB)
MD5
b2864eda3bd2aa9f79f36b557fa8fb51
SHA1
a13051b3a043458e53e10fb00789f58de87c99df
SHA256
4dd121f7486c29ddc356b7d9ead81e3948a919a4f11ec0c86d89d488fafb1fc7
SHA512

      
    
SHA1_git
49e16e997c32659329b21472ed626463e0d6b6d9
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ValueEnumBase.java | 3.2 KB |

/* * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.value; import java.math.BigDecimal; import org.h2.engine.CastDataProvider; import org.h2.util.StringUtils; /** * Base implementation of the ENUM data type. * * This base implementation is only used in 2.0.* clients when they work with * 1.4.* servers. */ public class ValueEnumBase extends Value { final String label; private final int ordinal; protected ValueEnumBase(final String label, final int ordinal) { this.label = label; this.ordinal = ordinal; } @Override public Value add(Value v) { ValueInteger iv = v.convertToInt(null); return convertToInt(null).add(iv); } @Override public int compareTypeSafe(Value v, CompareMode mode, CastDataProvider provider) { return Integer.compare(getInt(), v.getInt()); } @Override public Value divide(Value v, TypeInfo quotientType) { ValueInteger iv = v.convertToInt(null); return convertToInt(null).divide(iv, quotientType); } @Override public boolean equals(final Object other) { return other instanceof ValueEnumBase && getInt() == ((ValueEnumBase) other).getInt(); } /** * Get or create an enum value with the given label and ordinal. * * @param label the label * @param ordinal the ordinal * @return the value */ public static ValueEnumBase get(String label, int ordinal) { return new ValueEnumBase(label, ordinal); } @Override public int getInt() { return ordinal; } @Override public long getLong() { return ordinal; } @Override public BigDecimal getBigDecimal() { return BigDecimal.valueOf(ordinal); } @Override public float getFloat() { return ordinal; } @Override public double getDouble() { return ordinal; } @Override public int getSignum() { return Integer.signum(ordinal); } @Override public StringBuilder getSQL(StringBuilder builder, int sqlFlags) { return StringUtils.quoteStringSQL(builder, label); } @Override public String getString() { return label; } @Override public TypeInfo getType() { return TypeInfo.TYPE_ENUM_UNDEFINED; } @Override public int getValueType() { return ENUM; } @Override public int getMemory() { return 120; } @Override public int hashCode() { int results = 31; results += getString().hashCode(); results += getInt(); return results; } @Override public Value modulus(Value v) { ValueInteger iv = v.convertToInt(null); return convertToInt(null).modulus(iv); } @Override public Value multiply(Value v) { ValueInteger iv = v.convertToInt(null); return convertToInt(null).multiply(iv); } @Override public Value subtract(Value v) { ValueInteger iv = v.convertToInt(null); return convertToInt(null).subtract(iv); } }
Detected license expression
mpl-2.0 AND epl-1.0
Detected license expression (SPDX)
MPL-2.0 AND EPL-1.0
Percentage of license text
2.7
Copyrights
- end_line: 2
  copyright: Copyright 2004-2023 H2 Group. Multiple-Licensed
  start_line: 2
Holders
- holder: H2 Group. Multiple-Licensed
  end_line: 2
  start_line: 2
Authors

      
    
License detections License expression License expression SPDX
mpl_2_0_and_epl_1_0-796bf8d7-f485-3520-923d-e6a4b1ecd2f3 mpl-2.0 AND epl-1.0 MPL-2.0 AND EPL-1.0
URL Start line End line
https://h2database.com/html/license.html 3 3
Package URL License Primary language
pkg:osgi/com.h2database.source@2.2.220