com.haulmont.chile.core.datatypes.Datatype.getJavaClass()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中com.haulmont.chile.core.datatypes.Datatype.getJavaClass()方法的一些代码示例,展示了Datatype.getJavaClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datatype.getJavaClass()方法的具体详情如下:
包路径:com.haulmont.chile.core.datatypes.Datatype
类名称:Datatype
方法名:getJavaClass

Datatype.getJavaClass介绍

[英]Java class representing this Datatype
[中]表示此数据类型的Java类

代码示例

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected <T> void register(Datatype datatype, Aggregation<T> aggregation) {
  aggregationByDatatype.put(datatype.getJavaClass(), aggregation);
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

@Override
public String getIdByJavaClass(Class<?> javaClass) {
  for (Map.Entry<String, Datatype> entry : datatypeById.entrySet()) {
    if (entry.getValue().getJavaClass().equals(javaClass))
      return entry.getKey();
  }
  throw new IllegalArgumentException("No datatype registered for " + javaClass);
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

public KeyValueMetaProperty(MetaClass metaClass, String name, Datatype datatype) {
  this.name = name;
  this.javaClass = datatype.getJavaClass();
  this.metaClass = metaClass;
  this.mandatory = false;
  this.range = new DatatypeRange(datatype);
  this.type = Type.DATATYPE;
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

@Override
  public void register(Datatype datatype, String id, boolean defaultForJavaClass) {
    Preconditions.checkNotNullArgument(datatype, "datatype is null");
    Preconditions.checkNotNullArgument(id, "id is null");
    log.trace("Register datatype: {}, id: {}, defaultForJavaClass: {}", datatype.getClass(), id, defaultForJavaClass);

    if (defaultForJavaClass) {
      datatypeByClass.put(datatype.getJavaClass(), datatype);
    }
    datatypeById.put(id, datatype);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected boolean isUuid(MetaProperty metaProperty) {
  return metaProperty.getRange().asDatatype().getJavaClass().equals(UUID.class);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected boolean isByteArray(MetaProperty metaProperty) {
  return metaProperty.getRange().asDatatype().getJavaClass().equals(byte[].class);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected boolean isUuid(MetaProperty metaProperty) {
  return metaProperty.getRange().asDatatype().getJavaClass().equals(UUID.class);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected boolean isByteArray(MetaProperty metaProperty) {
  return metaProperty.getRange().asDatatype().getJavaClass().equals(byte[].class);
}

代码示例来源:origin: com.haulmont.charts/charts-gui

protected boolean isByteArray(MetaProperty metaProperty) {
  return metaProperty.getRange().asDatatype().getJavaClass().equals(byte[].class);
}

代码示例来源:origin: com.haulmont.charts/charts-gui

protected boolean isUuid(MetaProperty metaProperty) {
  return metaProperty.getRange().asDatatype().getJavaClass().equals(UUID.class);
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

protected Object readSimpleProperty(JsonElement valueElement, Datatype propertyType) {
  String value = valueElement.getAsString();
  if (value == null) return null;
  try {
    Class javaClass = propertyType.getJavaClass();
    if (BigDecimal.class.isAssignableFrom(javaClass)) {
      return valueElement.getAsBigDecimal();
    } else if (Long.class.isAssignableFrom(javaClass)) {
      return valueElement.getAsLong();
    } else if (Integer.class.isAssignableFrom(javaClass)) {
      return valueElement.getAsInt();
    } else if (Double.class.isAssignableFrom(javaClass)) {
      return valueElement.getAsDouble();
    }
    return propertyType.parse(value);
  } catch (ParseException e) {
    throw new EntitySerializationException(String.format("An error occurred while parsing property. Type [%s]. Value [%s].", propertyType, value), e);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

@SuppressWarnings("unchecked")
@Override
protected V convertToModel(LocalDate componentRawValue) throws ConversionException {
  if (componentRawValue == null) {
    return null;
  }
  LocalDateTime localDateTime = LocalDateTime.of(componentRawValue, LocalTime.MIDNIGHT);
  ValueSource<V> valueSource = getValueSource();
  if (valueSource instanceof EntityValueSource) {
    MetaProperty metaProperty = ((EntityValueSource) valueSource).getMetaPropertyPath().getMetaProperty();
    return (V) convertFromLocalDateTime(localDateTime, metaProperty.getRange().asDatatype().getJavaClass());
  }
  return (V) convertFromLocalDateTime(localDateTime, datatype == null ? Date.class : datatype.getJavaClass());
}

代码示例来源:origin: com.haulmont.fts/fts-core

protected boolean isSearchableProperty(MetaProperty metaProperty) {
    if (Arrays.binarySearch(systemProps, metaProperty.getName()) >= 0)
      return false;

    if (metaProperty.getRange().isDatatype()) {
      Class type = metaProperty.getRange().asDatatype().getJavaClass();
      return (type.equals(String.class)
          || type.equals(java.sql.Date.class)
          || type.equals(BigDecimal.class)
          || type.equals(Integer.class)
          || type.equals(Long.class)
          || type.equals(Double.class));

    } else if (metaProperty.getRange().isEnum() || metaProperty.getRange().isClass()) {
      return true;
    }

    return false;
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

@Override
@SuppressWarnings("unchecked")
protected V convertToModel(LocalTime componentRawValue) throws ConversionException {
  if (componentRawValue == null) {
    return null;
  }
  ValueSource<V> valueSource = getValueSource();
  if (valueSource instanceof EntityValueSource) {
    MetaProperty metaProperty = ((EntityValueSource) valueSource).getMetaPropertyPath().getMetaProperty();
    return (V) dateTimeTransformations.transformFromLocalTime(componentRawValue,
        metaProperty.getRange().asDatatype().getJavaClass());
  }
  return (V) dateTimeTransformations.transformFromLocalTime(componentRawValue,
      datatype == null ? Date.class : datatype.getJavaClass());
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Deprecated
protected Field.Validator getDefaultValidator(MetaProperty property) {
  Field.Validator validator = null;
  if (property.getRange().isDatatype()) {
    Messages messages = getMessages();
    Class type = property.getRange().asDatatype().getJavaClass();
    if (type.equals(Integer.class)) {
      validator = new IntegerValidator(messages.getMainMessage("validation.invalidNumber"));
    } else if (type.equals(Long.class)) {
      validator = new LongValidator(messages.getMainMessage("validation.invalidNumber"));
    } else if (type.equals(Double.class) || type.equals(BigDecimal.class)) {
      validator = new DoubleValidator(messages.getMainMessage("validation.invalidNumber"));
    } else if (type.equals(java.sql.Date.class)) {
      validator = new DateValidator(messages.getMainMessage("validation.invalidDate"));
    }
  }
  return validator;
}

代码示例来源:origin: de.diedavids.cuba.entitysoftreference/entity-soft-reference-web

@Nullable
@Override
public Component createComponent(ComponentGenerationContext context) {
  String property = context.getProperty();
  MetaPropertyPath mpp = resolveMetaPropertyPath(context.getMetaClass(), property);
  if (mpp != null) {
    Range mppRange = mpp.getRange();
    if (mppRange.isDatatype()) {
      Class type = mppRange.asDatatype().getJavaClass();
      if (type.equals(Entity.class)) {
        return createDatatypeLinkField(context);
      }
    }
  }
  return null;
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected Consumer getValidator(MetaProperty property) {
  Consumer validator = null;
  if (property.getRange().isDatatype()) {
    Class type = property.getRange().asDatatype().getJavaClass();
    if (type.equals(Integer.class)) {
      validator = new IntegerValidator(messages.getMainMessage("validation.invalidNumber"));
    } else if (type.equals(Long.class)) {
      validator = new LongValidator(messages.getMainMessage("validation.invalidNumber"));
    } else if (type.equals(Double.class) || type.equals(BigDecimal.class)) {
      validator = new DoubleValidator(messages.getMainMessage("validation.invalidNumber"));
    } else if (type.equals(java.sql.Date.class)) {
      validator = new DateValidator(messages.getMainMessage("validation.invalidDate"));
    }
  }
  return validator;
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected Field createDateField(Datasource datasource, MetaProperty property) {
  Class type = property.getRange().asDatatype().getJavaClass();
  DateField dateField = componentsFactory.createComponent(DateField.class);
  dateField.setDatasource(datasource, property.getName());
  if (type.equals(Date.class)) {
    dateField.setResolution(DateField.Resolution.DAY);
    dateField.setDateFormat(messages.getMainMessage("dateTimeFormat"));
  } else if (type.equals(java.sql.Date.class)) {
    dateField.setResolution(DateField.Resolution.SEC);
    dateField.setDateFormat(messages.getMainMessage("dateFormat"));
  } else {
    throw new RuntimeException("Unknown type for " + property);
  }
  return dateField;
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

public void setupZoneId(DateField component, EntityValueSource valueSource) {
  if (component.getZoneId() == null) {
    MetaProperty metaProperty = valueSource.getMetaPropertyPath().getMetaProperty();
    Class javaType = metaProperty.getRange().asDatatype().getJavaClass();
    if (dateTimeTransformations.isDateTypeSupportsTimeZones(javaType)) {
      Boolean ignoreUserTimeZone = metadataTools.getMetaAnnotationValue(metaProperty, IgnoreUserTimeZone.class);
      if (!Boolean.TRUE.equals(ignoreUserTimeZone)) {
        TimeZone timeZone = userSessionSource.getUserSession().getTimeZone();
        component.setTimeZone(timeZone);
      }
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

public void setupDateFormat(DateField component, EntityValueSource valueSource) {
  MetaProperty metaProperty = valueSource.getMetaPropertyPath().getMetaProperty();
  Class javaType = metaProperty.getRange().asDatatype().getJavaClass();
  TemporalType temporalType = getTemporalType(metaProperty, javaType);
  component.setResolution(temporalType == TemporalType.DATE
      ? DateField.Resolution.DAY
      : DateField.Resolution.MIN);
  String formatStr = messageTools.getDefaultDateFormat(temporalType);
  component.setDateFormat(formatStr);
}

相关文章