当前位置: 首页>>代码示例>>Java>>正文


Java UUIDs类代码示例

本文整理汇总了Java中com.datastax.driver.core.utils.UUIDs的典型用法代码示例。如果您正苦于以下问题:Java UUIDs类的具体用法?Java UUIDs怎么用?Java UUIDs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UUIDs类属于com.datastax.driver.core.utils包,在下文中一共展示了UUIDs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
public static void main(String[] args) {

		Session session = Connection.connect();		
		PreparedStatement preparedStatement = session.prepare("insert into user (id, name, age) values (?, ?, ?)");

		try {
			BoundStatement boundStatement = preparedStatement.bind(UUIDs.timeBased(), "Hector", 34);
			ResultSet rs = session.execute(boundStatement);
			System.out.println(rs);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		
		Connection.close();

	}
 
开发者ID:abulbasar,项目名称:cassandra-java-driver-examples,代码行数:17,代码来源:PreparedStatementExample.java

示例2: main

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
public static void main(String[] args) {

		Session session = Connection.connect();		
		BatchStatement batchStatement = new BatchStatement();
		
		PreparedStatement preparedStatement = session.prepare("insert into user (id, name) values (?, ?)");
		int i = 0;
		while(i < 10) {
			batchStatement.add(preparedStatement.bind(UUIDs.timeBased(), "user-" + i));
			++i;
		}

		try {
			ResultSet rs = session.execute(batchStatement);
			System.out.println(rs);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		Connection.close();

	}
 
开发者ID:abulbasar,项目名称:cassandra-java-driver-examples,代码行数:22,代码来源:BatchStatementExample.java

示例3: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Alarm toData() {
    Alarm alarm = new Alarm(new AlarmId(id));
    alarm.setCreatedTime(UUIDs.unixTimestamp(id));
    if (tenantId != null) {
        alarm.setTenantId(new TenantId(tenantId));
    }
    alarm.setOriginator(EntityIdFactory.getByTypeAndUuid(originatorType, originatorId));
    alarm.setType(type);
    alarm.setSeverity(severity);
    alarm.setStatus(status);
    alarm.setPropagate(propagate);
    alarm.setStartTs(startTs);
    alarm.setEndTs(endTs);
    alarm.setAckTs(ackTs);
    alarm.setClearTs(clearTs);
    alarm.setDetails(details);
    return alarm;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:20,代码来源:AlarmEntity.java

示例4: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public WidgetsBundle toData() {
    WidgetsBundle widgetsBundle = new WidgetsBundle(new WidgetsBundleId(id));
    widgetsBundle.setCreatedTime(UUIDs.unixTimestamp(id));
    if (tenantId != null) {
        widgetsBundle.setTenantId(new TenantId(tenantId));
    }
    widgetsBundle.setAlias(alias);
    widgetsBundle.setTitle(title);
    if (image != null) {
        byte[] imageByteArray = new byte[image.remaining()];
        image.get(imageByteArray);
        widgetsBundle.setImage(imageByteArray);
    }
    return widgetsBundle;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:17,代码来源:WidgetsBundleEntity.java

示例5: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Customer toData() {
    Customer customer = new Customer(new CustomerId(id));
    customer.setCreatedTime(UUIDs.unixTimestamp(id));
    customer.setTenantId(new TenantId(tenantId));
    customer.setTitle(title);
    customer.setCountry(country);
    customer.setState(state);
    customer.setCity(city);
    customer.setAddress(address);
    customer.setAddress2(address2);
    customer.setZip(zip);
    customer.setPhone(phone);
    customer.setEmail(email);
    customer.setAdditionalInfo(additionalInfo);
    return customer;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:CustomerEntity.java

示例6: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
  public User toData() {
User user = new User(new UserId(id));
user.setCreatedTime(UUIDs.unixTimestamp(id));
user.setAuthority(authority);
if (tenantId != null) {
	user.setTenantId(new TenantId(tenantId));
}
if (customerId != null) {
	user.setCustomerId(new CustomerId(customerId));
}
user.setEmail(email);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setAdditionalInfo(additionalInfo);
      return user;
  }
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:UserEntity.java

示例7: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Tenant toData() {
    Tenant tenant = new Tenant(new TenantId(id));
    tenant.setCreatedTime(UUIDs.unixTimestamp(id));
    tenant.setTitle(title);
    tenant.setRegion(region);
    tenant.setCountry(country);
    tenant.setState(state);
    tenant.setCity(city);
    tenant.setAddress(address);
    tenant.setAddress2(address2);
    tenant.setZip(zip);
    tenant.setPhone(phone);
    tenant.setEmail(email);
    tenant.setAdditionalInfo(additionalInfo);
    return tenant;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:TenantEntity.java

示例8: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Alarm toData() {
    Alarm alarm = new Alarm(new AlarmId(UUIDConverter.fromString(id)));
    alarm.setCreatedTime(UUIDs.unixTimestamp(UUIDConverter.fromString(id)));
    if (tenantId != null) {
        alarm.setTenantId(new TenantId(UUIDConverter.fromString(tenantId)));
    }
    alarm.setOriginator(EntityIdFactory.getByTypeAndUuid(originatorType, UUIDConverter.fromString(originatorId)));
    alarm.setType(type);
    alarm.setSeverity(severity);
    alarm.setStatus(status);
    alarm.setPropagate(propagate);
    alarm.setStartTs(startTs);
    alarm.setEndTs(endTs);
    alarm.setAckTs(ackTs);
    alarm.setClearTs(clearTs);
    alarm.setDetails(details);
    return alarm;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:20,代码来源:AlarmEntity.java

示例9: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Customer toData() {
    Customer customer = new Customer(new CustomerId(getId()));
    customer.setCreatedTime(UUIDs.unixTimestamp(getId()));
    customer.setTenantId(new TenantId(UUIDConverter.fromString(tenantId)));
    customer.setTitle(title);
    customer.setCountry(country);
    customer.setState(state);
    customer.setCity(city);
    customer.setAddress(address);
    customer.setAddress2(address2);
    customer.setZip(zip);
    customer.setPhone(phone);
    customer.setEmail(email);
    customer.setAdditionalInfo(additionalInfo);
    return customer;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:CustomerEntity.java

示例10: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public User toData() {
  User user = new User(new UserId(getId()));
  user.setCreatedTime(UUIDs.unixTimestamp(getId()));
  user.setAuthority(authority);
  if (tenantId != null) {
    user.setTenantId(new TenantId(UUIDConverter.fromString(tenantId)));
  }
  if (customerId != null) {
    user.setCustomerId(new CustomerId(UUIDConverter.fromString(customerId)));
  }
  user.setEmail(email);
  user.setFirstName(firstName);
  user.setLastName(lastName);
  user.setAdditionalInfo(additionalInfo);
  return user;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:UserEntity.java

示例11: toData

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Tenant toData() {
    Tenant tenant = new Tenant(new TenantId(getId()));
    tenant.setCreatedTime(UUIDs.unixTimestamp(getId()));
    tenant.setTitle(title);
    tenant.setRegion(region);
    tenant.setCountry(country);
    tenant.setState(state);
    tenant.setCity(city);
    tenant.setAddress(address);
    tenant.setAddress2(address2);
    tenant.setZip(zip);
    tenant.setPhone(phone);
    tenant.setEmail(email);
    tenant.setAdditionalInfo(additionalInfo);
    return tenant;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:TenantEntity.java

示例12: save

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
private Optional<Event> save(EventEntity entity, boolean ifNotExists) {
    if (entity.getId() == null) {
        entity.setId(UUIDs.timeBased());
    }
    Insert insert = QueryBuilder.insertInto(getColumnFamilyName())
            .value(ModelConstants.ID_PROPERTY, entity.getId())
            .value(ModelConstants.EVENT_TENANT_ID_PROPERTY, entity.getTenantId())
            .value(ModelConstants.EVENT_ENTITY_TYPE_PROPERTY, entity.getEntityType())
            .value(ModelConstants.EVENT_ENTITY_ID_PROPERTY, entity.getEntityId())
            .value(ModelConstants.EVENT_TYPE_PROPERTY, entity.getEventType())
            .value(ModelConstants.EVENT_UID_PROPERTY, entity.getEventUid())
            .value(ModelConstants.EVENT_BODY_PROPERTY, entity.getBody());
    if (ifNotExists) {
        insert = insert.ifNotExists();
    }
    ResultSet rs = executeWrite(insert);
    if (rs.wasApplied()) {
        return Optional.of(DaoUtil.getData(entity));
    } else {
        return Optional.empty();
    }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:23,代码来源:CassandraBaseEventDao.java

示例13: save

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
@Transactional
public D save(D domain) {
    E entity;
    try {
        entity = getEntityClass().getConstructor(domain.getClass()).newInstance(domain);
    } catch (Exception e) {
        log.error("Can't create entity for domain object {}", domain, e);
        throw new IllegalArgumentException("Can't create entity for domain object {" + domain + "}", e);
    }
    setSearchText(entity);
    log.debug("Saving entity {}", entity);
    if (entity.getId() == null) {
        entity.setId(UUIDs.timeBased());
    }
    entity = getCrudRepository().save(entity);
    return DaoUtil.getData(entity);
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:19,代码来源:JpaAbstractDao.java

示例14: save

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
public Optional<Event> save(EventEntity entity, boolean ifNotExists) {
    log.debug("Save event [{}] ", entity);
    if (entity.getTenantId() == null) {
        log.trace("Save system event with predefined id {}", systemTenantId);
        entity.setTenantId(UUIDConverter.fromTimeUUID(systemTenantId));
    }
    if (entity.getId() == null) {
        entity.setId(UUIDs.timeBased());
    }
    if (StringUtils.isEmpty(entity.getEventUid())) {
        entity.setEventUid(entity.getId().toString());
    }
    if (ifNotExists &&
            eventRepository.findByTenantIdAndEntityTypeAndEntityId(entity.getTenantId(), entity.getEntityType(), entity.getEntityId()) != null) {
        return Optional.empty();
    }
    return Optional.of(DaoUtil.getData(eventRepository.save(entity)));
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:19,代码来源:JpaBaseEventDao.java

示例15: saveIfNotExist

import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
private Optional<ComponentDescriptor> saveIfNotExist(ComponentDescriptorEntity entity) {
    if (entity.getId() == null) {
        entity.setId(UUIDs.timeBased());
    }

    ResultSet rs = executeRead(QueryBuilder.insertInto(getColumnFamilyName())
            .value(ModelConstants.ID_PROPERTY, entity.getId())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_NAME_PROPERTY, entity.getName())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_CLASS_PROPERTY, entity.getClazz())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_TYPE_PROPERTY, entity.getType())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_SCOPE_PROPERTY, entity.getScope())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_CONFIGURATION_DESCRIPTOR_PROPERTY, entity.getConfigurationDescriptor())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_ACTIONS_PROPERTY, entity.getActions())
            .value(ModelConstants.SEARCH_TEXT_PROPERTY, entity.getSearchText())
            .ifNotExists()
    );
    if (rs.wasApplied()) {
        return Optional.of(DaoUtil.getData(entity));
    } else {
        return Optional.empty();
    }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:23,代码来源:CassandraBaseComponentDescriptorDao.java


注:本文中的com.datastax.driver.core.utils.UUIDs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。