/** * 取得结果字符串 * * @param result * @return */ protected String getResultString(Object result) { if (result == null) { return StringUtils.EMPTY; } if (result instanceof Map) { // 处理map return getMapResultString((Map) result); } else if (result instanceof List) {// 处理list return getListResultString((List) result); } else if (result.getClass().isArray()) {// 处理array return getArrayResultString((Object[]) result); } else { // 直接处理string return ObjectUtils.toString(result, StringUtils.EMPTY).toString(); // return ToStringBuilder.reflectionToString(result, ToStringStyle.SIMPLE_STYLE); } }
public int compare(ResolvedArtifact artifact1, ResolvedArtifact artifact2) { int diff = artifact1.getName().compareTo(artifact2.getName()); if (diff != 0) { return diff; } diff = ObjectUtils.compare(artifact1.getClassifier(), artifact2.getClassifier()); if (diff != 0) { return diff; } diff = ObjectUtils.compare(artifact1.getExtension(), artifact2.getExtension()); if (diff != 0) { return diff; } diff = artifact1.getType().compareTo(artifact2.getType()); if (diff != 0) { return diff; } // Use an arbitrary ordering when the artifacts have the same public attributes return artifact1.hashCode() - artifact2.hashCode(); }
public void insert(List<CanalEntry.Column> data, String schemaName, String tableName) { DBObject obj = DBConvertUtil.columnToJson(data); logger.debug("insert :{}", obj.toString()); //订单库单独处理 if (schemaName.equals("order")) { //保存原始数据 if (tableName.startsWith("order_base_info")) { tableName = "order_base_info"; } else if (tableName.startsWith("order_detail_info")) { tableName = "order_detail_info"; } else { logger.info("unknown data :{}.{}:{}", schemaName, tableName, obj); return; } insertData(schemaName, tableName, obj, obj); } else { DBObject newObj = (DBObject) ObjectUtils.clone(obj); if (newObj.containsField("id")) { newObj.put("_id", newObj.get("id")); newObj.removeField("id"); } insertData(schemaName, tableName, newObj, obj); } }
public void insertData(String schemaName, String tableName, DBObject naive, DBObject complete) { int i = 0; DBObject logObj = (DBObject) ObjectUtils.clone(complete); //保存原始数据 try { String path = "/" + schemaName + "/" + tableName + "/" + CanalEntry.EventType.INSERT.getNumber(); i++; naiveMongoTemplate.getCollection(tableName).insert(naive); i++; SpringUtil.doEvent(path, complete); i++; } catch (MongoClientException | MongoSocketException clientException) { //客户端连接异常抛出,阻塞同步,防止mongodb宕机 throw clientException; } catch (Exception e) { logError(schemaName, tableName, 1, i, logObj, e); } }
public void updateData(String schemaName, String tableName, DBObject query, DBObject obj) { String path = "/" + schemaName + "/" + tableName + "/" + CanalEntry.EventType.UPDATE.getNumber(); int i = 0; DBObject newObj = (DBObject) ObjectUtils.clone(obj); DBObject logObj = (DBObject) ObjectUtils.clone(obj); //保存原始数据 try { obj.removeField("id"); i++; naiveMongoTemplate.getCollection(tableName).update(query, obj); i++; SpringUtil.doEvent(path, newObj); i++; } catch (MongoClientException | MongoSocketException clientException) { //客户端连接异常抛出,阻塞同步,防止mongodb宕机 throw clientException; } catch (Exception e) { logError(schemaName, tableName, 2, i, logObj, e); } }
public void deleteData(String schemaName, String tableName, DBObject obj) { int i = 0; String path = "/" + schemaName + "/" + tableName + "/" + CanalEntry.EventType.DELETE.getNumber(); DBObject newObj = (DBObject) ObjectUtils.clone(obj); DBObject logObj = (DBObject) ObjectUtils.clone(obj); //保存原始数据 try { i++; if (obj.containsField("id")) { naiveMongoTemplate.getCollection(tableName).remove(new BasicDBObject("_id", obj.get("id"))); } i++; SpringUtil.doEvent(path, newObj); } catch (MongoClientException | MongoSocketException clientException) { //客户端连接异常抛出,阻塞同步,防止mongodb宕机 throw clientException; } catch (Exception e) { logError(schemaName, tableName, 3, i, logObj, e); } }
/** * @param task Task * @param properties Map<QName, Serializable> */ private void setTaskOwner(Task task, Map<QName, Serializable> properties) { QName ownerKey = ContentModel.PROP_OWNER; if (properties.containsKey(ownerKey)) { Serializable owner = properties.get(ownerKey); if (owner != null && !(owner instanceof String)) { throw getInvalidPropertyValueException(ownerKey, owner); } String assignee = (String) owner; String currentAssignee = task.getAssignee(); // Only set the assignee if the value has changes to prevent // triggering assignementhandlers when not needed if (ObjectUtils.equals(currentAssignee, assignee)==false) { activitiUtil.getTaskService().setAssignee(task.getId(), assignee); } } }
/** * Check if this extended message format is equal to another object. * * @param obj the object to compare to * @return true if this object equals the other, otherwise false * @since 2.6 */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null) { return false; } if (!super.equals(obj)) { return false; } if (ObjectUtils.notEqual(getClass(), obj.getClass())) { return false; } ExtendedMessageFormat rhs = (ExtendedMessageFormat)obj; if (ObjectUtils.notEqual(toPattern, rhs.toPattern)) { return false; } if (ObjectUtils.notEqual(registry, rhs.registry)) { return false; } return true; }
private int compareKeys(Optional<Record> record1, Optional<Record> record2, List<Column> primaryKeys) { if (!record1.isPresent() && !record2.isPresent()) { throw new IllegalStateException("Cannot compare two nonexistent records."); } if (!record1.isPresent()) { return 1; } if (!record2.isPresent()) { return -1; } for (Column keyCol : primaryKeys) { Comparable<?> value1 = convertToComparableType(keyCol, record1.get()); Comparable<?> value2 = convertToComparableType(keyCol, record2.get()); int result = ObjectUtils.compare(value1, value2); if (result != 0) { return result; } } return 0; }
/** * Compare all the columns for these records. * * @param table the active {@link Table} * @param recordNumber The current record number * @param record1 The first record * @param record2 The second record */ private void compareRecords(Table table, int recordNumber, Record record1, Record record2, List<Column> primaryKeys) { for (Column column : FluentIterable.from(table.columns()).filter(excludingExcludedColumns())) { String columnName = column.getName(); Object value1 = convertToComparableType(column, record1); Object value2 = convertToComparableType(column, record2); if (!ObjectUtils.equals(value1, value2)) { differences.add(String.format( "Table [%s]: Mismatch on key %s column [%s] row [%d]: [%s]<>[%s]", table.getName(), keyColumnsIds(record1, record2, primaryKeys), columnName, recordNumber, value1, value2 )); } } }
public static void dumpApplierInfo(Long batchId, List<Record> extractorRecords, List<Record> applierRecords, Position position, boolean dumpDetail) { applierLogger.info(SEP + "****************************************************" + SEP); Date now = new Date(); SimpleDateFormat format = new SimpleDateFormat(TIMESTAMP_FORMAT); applierLogger.info(MessageFormat.format(applier_format, String.valueOf(batchId), extractorRecords.size(), applierRecords.size(), ObjectUtils.toString(position), format.format(now))); applierLogger.info("****************************************************" + SEP); if (dumpDetail) {// 判断一下是否需要打印详细信息,目前只打印applier信息,分开打印 applierLogger.info(dumpRecords(applierRecords)); applierLogger.info("****************************************************" + SEP); } }
/** * 快速生成一个map的工具类 * @author nan.li * @param objects * @return */ public static Map<String, Object> asMap(Object... objects) { Map<String, Object> ret = new HashMap<>(); if (objects != null && objects.length > 0 && objects.length % 2 == 0) { for (int i = 0; i + 1 < objects.length; i += 2) { ret.put(ObjectUtils.toString(objects[i]), objects[i + 1]); } } else { Logs.w("参数个数非法!"); } return ret; }
/** * 返回一个String Map * @author nan.li * @param objects * @return */ public static Map<String, String> asStrMap(Object... objects) { Map<String, String> ret = new HashMap<>(); if (objects != null && objects.length > 0 && objects.length % 2 == 0) { for (int i = 0; i + 1 < objects.length; i += 2) { ret.put(ObjectUtils.toString(objects[i]), ObjectUtils.toString(objects[i + 1])); } } else { Logs.w("参数个数非法!"); } return ret; }
@Override public void execute() throws ServiceAbortException { page.clearErrorMessageList(); String password = page.getPassword(); String passwordConf = page.getPasswordConf(); if (!ObjectUtils.equals(password, passwordConf)) { throw new ServiceAbortException(ApplicationMessageCode.PASSWORD_UNMATCH); } else { page.setContextUser(SETUP_USER_ID); List<SysUsers> userList = new ArrayList<>(); userList.add(setupUserDto()); page.userService.save(userList); page.setVisibled(3); page.setPageTitle(3); page.setBackPage(2); } }
protected void sortProjectRoles(List<ProjectRole> projectRoles) { Collections.sort(projectRoles, new Comparator<ProjectRole>() { private Map<ProjectRoleCode, Integer> order = ImmutableMap.<ProjectRoleCode, Integer>builder() .put(ProjectRoleCode.WORKER, 1) .put(ProjectRoleCode.MANAGER, 2) .put(ProjectRoleCode.APPROVER, 3) .put(ProjectRoleCode.OBSERVER, 4).build(); @Override public int compare(ProjectRole o1, ProjectRole o2) { ProjectRoleCode code1 = o1.getCode(); ProjectRoleCode code2 = o2.getCode(); Integer order1 = order.get(code1); Integer order2 = order.get(code2); return ObjectUtils.compare(order1, order2); } }); }
private void createOrupdateConfigObject(final Date date, final String componentName, final ConfigKey<?> key, final String value) { ConfigurationVO vo = _configDao.findById(key.key()); if (vo == null) { vo = new ConfigurationVO(componentName, key); vo.setUpdated(date); if (value != null) { vo.setValue(value); } _configDao.persist(vo); } else { if (vo.isDynamic() != key.isDynamic() || !ObjectUtils.equals(vo.getDescription(), key.description()) || !ObjectUtils.equals(vo.getDefaultValue(), key.defaultValue()) || !ObjectUtils.equals(vo.getScope(), key.scope().toString()) || !ObjectUtils.equals(vo.getComponent(), componentName)) { vo.setDynamic(key.isDynamic()); vo.setDescription(key.description()); vo.setDefaultValue(key.defaultValue()); vo.setScope(key.scope().toString()); vo.setComponent(componentName); vo.setUpdated(date); _configDao.persist(vo); } } }
@SuppressWarnings("unchecked") protected <V extends Comparable<V>> void sort(List<T> list) { Collections.sort(list, new Comparator<T>() { @Override public int compare(T o1, T o2) { SortParam<String> sortParam = getSort(); String propertyName = sortParam.getProperty(); V prop1, prop2; try { prop1 = (V) PropertyUtils.getProperty(o1, propertyName); prop2 = (V) PropertyUtils.getProperty(o2, propertyName); } catch (RuntimeException|IllegalAccessException|InvocationTargetException|NoSuchMethodException e) { throw new SystemException("Couldn't sort the object list: " + e.getMessage(), e); } int comparison = ObjectUtils.compare(prop1, prop2, true); return sortParam.isAscending() ? comparison : -comparison; } }); }
private void updatePortAndContextPath(HttpServletRequest request) { int port = Integer.parseInt(System.getProperty("subsonic.port", String.valueOf(request.getLocalPort()))); int httpsPort = Integer.parseInt(System.getProperty("subsonic.httpsPort", "0")); String contextPath = request.getContextPath().replace("/", ""); if (settingsService.getPort() != port) { settingsService.setPort(port); settingsService.save(); } if (settingsService.getHttpsPort() != httpsPort) { settingsService.setHttpsPort(httpsPort); settingsService.save(); } if (!ObjectUtils.equals(settingsService.getUrlRedirectContextPath(), contextPath)) { settingsService.setUrlRedirectContextPath(contextPath); settingsService.save(); } }
public static boolean isEqualStyle(TextStyleType s1, TextStyleType s2) { return ( ObjectUtils.equals(s1.getFontFamily(), s2.getFontFamily()) && ObjectUtils.equals(s1.isSerif(), s2.isSerif()) && ObjectUtils.equals(s1.isMonospace(), s2.isMonospace()) && ObjectUtils.equals(s1.getFontSize(), s2.getFontSize()) && ObjectUtils.equals(s1.getKerning(), s2.getKerning()) && ObjectUtils.equals( s1.getTextColour(), s2.getTextColour()) && ObjectUtils.equals(s1.getBgColour(), s2.getBgColour()) && ObjectUtils.equals(s1.isReverseVideo(), s2.isReverseVideo()) && ObjectUtils.equals(s1.isBold(), s2.isBold()) && ObjectUtils.equals(s1.isItalic(), s2.isItalic()) && ObjectUtils.equals(s1.isUnderlined(), s2.isUnderlined()) && ObjectUtils.equals(s1.isSubscript(), s2.isSubscript()) && ObjectUtils.equals(s1.isSuperscript(), s2.isSuperscript()) && ObjectUtils.equals(s1.isStrikethrough(), s2.isStrikethrough()) && ObjectUtils.equals(s1.isSmallCaps(), s2.isSmallCaps()) && ObjectUtils.equals(s1.isLetterSpaced(), s2.isLetterSpaced()) ); }
/** * Check if the given request is allowed on the whitelist */ public boolean isAllowed(final String host, final String addr) { final boolean allowed = isAllowed(addr); if (allowed) { return true; } if (ObjectUtils.equals(host, addr)) { // Try to resolve the host name to one of the known hosts for (final String current : getAllowedHosts()) { try { // Check if one of the addresses on the whitelisted hosts is the request address final InetAddress[] addresses = InetAddress.getAllByName(current); for (final InetAddress address : addresses) { if (address.getHostAddress().equals(addr)) { return true; } } } catch (final UnknownHostException e) { // Go on } } return false; } else { return isAllowed(host); } }
/** * Set the value of StationFrom * * @param v new value */ public void setStationFrom(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.stationFrom, v)) { this.stationFrom = v; setModified(true); } if (aTWorkflowStationRelatedByStationFrom != null && !ObjectUtils.equals(aTWorkflowStationRelatedByStationFrom.getObjectID(), v)) { aTWorkflowStationRelatedByStationFrom = null; } }
/** * Set the value of ListType * * @param v new value */ public void setListType(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.listType, v)) { this.listType = v; setModified(true); } if (aTListType != null && !ObjectUtils.equals(aTListType.getObjectID(), v)) { aTListType = null; } }
/** * Set the value of IssueTypeChild * * @param v new value */ public void setIssueTypeChild(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.issueTypeChild, v)) { this.issueTypeChild = v; setModified(true); } if (aTListTypeRelatedByIssueTypeChild != null && !ObjectUtils.equals(aTListTypeRelatedByIssueTypeChild.getObjectID(), v)) { aTListTypeRelatedByIssueTypeChild = null; } }
/** * Set the value of Owner * * @param v new value */ public void setOwner(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.owner, v)) { this.owner = v; setModified(true); } if (aTPersonRelatedByOwner != null && !ObjectUtils.equals(aTPersonRelatedByOwner.getObjectID(), v)) { aTPersonRelatedByOwner = null; } }
/** * Set the value of ProjectType * * @param v new value */ public void setProjectType(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.projectType, v)) { this.projectType = v; setModified(true); } if (aTProjectType != null && !ObjectUtils.equals(aTProjectType.getObjectID(), v)) { aTProjectType = null; } }
/** * Set the value of ProjectID * * @param v new value */ public void setProjectID(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.projectID, v)) { this.projectID = v; setModified(true); } if (aTProject != null && !ObjectUtils.equals(aTProject.getObjectID(), v)) { aTProject = null; } }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } final HistoricalVolatilityHighLowCloseCalculator other = (HistoricalVolatilityHighLowCloseCalculator) obj; if (!ObjectUtils.equals(_relativeReturnCalculator, other._relativeReturnCalculator)) { return false; } return ObjectUtils.equals(_returnCalculator, other._returnCalculator); }
/** * Set the value of StateID * * @param v new value */ public void setStateID(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.stateID, v)) { this.stateID = v; setModified(true); } if (aTState != null && !ObjectUtils.equals(aTState.getObjectID(), v)) { aTState = null; } }
/** * Set the value of ObjectID * * @param v new value */ public void setObjectID(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.objectID, v)) { this.objectID = v; setModified(true); } // update associated TWorkItemLink if (collTWorkItemLinks != null) { for (int i = 0; i < collTWorkItemLinks.size(); i++) { ((TWorkItemLink) collTWorkItemLinks.get(i)) .setLinkType(v); } } }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof CarrLeeFXData)) { return false; } final CarrLeeFXData other = (CarrLeeFXData) obj; if (Double.compare(_realizedVariance, other._realizedVariance) != 0) { return false; } if (!ObjectUtils.equals(_currencyPair, other._currencyPair)) { return false; } if (!ObjectUtils.equals(_curves, other._curves)) { return false; } if (!ObjectUtils.equals(_volatilitySurface, other._volatilitySurface)) { return false; } return true; }
/** * Set the value of RequiredOption * * @param v new value */ public void setRequiredOption(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.requiredOption, v)) { this.requiredOption = v; setModified(true); } if (aTAttributeOption != null && !ObjectUtils.equals(aTAttributeOption.getObjectID(), v)) { aTAttributeOption = null; } }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final PriceIndexCurveAddPriceIndexSpreadCurve other = (PriceIndexCurveAddPriceIndexSpreadCurve) obj; if (!ObjectUtils.equals(_curves, other._curves)) { return false; } if (Double.doubleToLongBits(_sign) != Double.doubleToLongBits(other._sign)) { return false; } return true; }
/** * Set the value of Department * * @param v new value */ public void setDepartment(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.department, v)) { this.department = v; setModified(true); } if (aTDepartment != null && !ObjectUtils.equals(aTDepartment.getObjectID(), v)) { aTDepartment = null; } }
/** * Set the value of ChangedBy * * @param v new value */ public void setChangedBy(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.changedBy, v)) { this.changedBy = v; setModified(true); } if (aTPerson != null && !ObjectUtils.equals(aTPerson.getObjectID(), v)) { aTPerson = null; } }
/** * Set the value of Superiorworkitem * * @param v new value */ public void setSuperiorworkitem(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.superiorworkitem, v)) { this.superiorworkitem = v; setModified(true); } if (aTWorkItemRelatedBySuperiorworkitem != null && !ObjectUtils.equals(aTWorkItemRelatedBySuperiorworkitem.getObjectID(), v)) { aTWorkItemRelatedBySuperiorworkitem = null; } }
/** * Set the value of Field * * @param v new value */ public void setField(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.field, v)) { this.field = v; setModified(true); } if (aTField != null && !ObjectUtils.equals(aTField.getObjectID(), v)) { aTField = null; } }
/** * Set the value of Owner * * @param v new value */ public void setOwner(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.owner, v)) { this.owner = v; setModified(true); } if (aTPerson != null && !ObjectUtils.equals(aTPerson.getObjectID(), v)) { aTPerson = null; } }
/** * Set the value of ParentList * * @param v new value */ public void setParentList(Integer v) throws TorqueException { if (!ObjectUtils.equals(this.parentList, v)) { this.parentList = v; setModified(true); } if (aTListRelatedByParentList != null && !ObjectUtils.equals(aTListRelatedByParentList.getObjectID(), v)) { aTListRelatedByParentList = null; } }