Example usage for java.util UUID UUID

List of usage examples for java.util UUID UUID

Introduction

In this page you can find the example usage for java.util UUID UUID.

Prototype

public UUID(long mostSigBits, long leastSigBits) 

Source Link

Document

Constructs a new UUID using the specified data.

Usage

From source file:info.archinnov.achilles.it.TestDSLEntityWithClusterings.java

@Test
public void should_dsl_select_slice_with_different_partitions() throws Exception {
    //Given//from   ww  w.  j a  va 2 s.  c o  m
    final Map<String, Object> values = new HashMap<>();
    final long id1 = RandomUtils.nextLong(0L, Long.MAX_VALUE);
    final long id2 = RandomUtils.nextLong(0L, Long.MAX_VALUE);

    values.put("id1", id1);
    values.put("id2", id1);
    values.put("id3", id1);
    values.put("id4", id2);
    values.put("id5", id2);

    final UUID uuid = new UUID(0L, 0L);

    values.put("uuid1", uuid);
    values.put("uuid2", uuid);
    values.put("uuid3", uuid);
    values.put("uuid4", uuid);
    values.put("uuid5", uuid);

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    final Date date3 = dateFormat.parse("2015-10-03 00:00:00 GMT");
    final Date date5 = dateFormat.parse("2015-10-05 00:00:00 GMT");

    values.put("date1", "'2015-10-01 00:00:00+0000'");
    values.put("date2", "'2015-10-02 00:00:00+0000'");
    values.put("date3", "'2015-10-03 00:00:00+0000'");
    values.put("date4", "'2015-10-04 00:00:00+0000'");
    values.put("date5", "'2015-10-05 00:00:00+0000'");

    scriptExecutor.executeScriptTemplate("EntityWithClusteringColumns/insert_many_rows.cql", values);

    /*
    Data are ordered as:
            
    id1, uuid, date3,
    id1, uuid, date2,
    id1, uuid, date1,
    id2, uuid, date5,
    id2, uuid, date4
            
    because date is ORDERED BY DESC natively
     */

    //When
    final List<EntityWithClusteringColumns> list = manager.dsl().select().uuid().date().value().fromBaseTable()
            .where().id_IN(id1, id2).uuid_Eq(uuid).date_IN(date3, date5).getList();

    //Then
    assertThat(list).hasSize(2);

    assertThat(list.stream().map(EntityWithClusteringColumns::getValue).sorted().collect(toList()))
            .containsExactly("val3", "val5");
}

From source file:org.cloudgraph.hbase.graph.DefaultAssembler.java

protected UUID fetchRootUUID(TableReader childTableReader, GraphColumnKeyFactory keyFactory, PlasmaType subType,
        CellValues childResult) {/* w  ww.  j ava 2s .  c  o m*/

    byte[] uuidQual = keyFactory.createColumnKey(subType, EntityMetaKey.UUID);
    byte[] rootUuid = childResult
            .getColumnValue(childTableReader.getTableConfig().getDataColumnFamilyNameBytes(), uuidQual);
    if (rootUuid == null)
        throw new GraphServiceException("expected column: " + Bytes.toString(uuidQual) + " for row '"
                + childResult.getRowKey() + "' in table: " + childTableReader.getTableConfig().getName());
    String uuidStr = new String(rootUuid, childTableReader.getTableConfig().getCharset());
    UUID uuid = null;
    if (uuidStr.length() == 22) {
        byte[] bytes = Base64.decodeBase64(uuidStr);
        ByteBuffer bb = ByteBuffer.wrap(bytes);
        uuid = new UUID(bb.getLong(), bb.getLong());
    } else {
        uuid = UUID.fromString(uuidStr);
    }
    return uuid;
}

From source file:de.undercouch.bson4jackson.BsonParserTest.java

@Test
public void parseBinary() throws Exception {
    byte[] b = new byte[] { 1, 2, 3, 4, 5 };
    BSONObject o = new BasicBSONObject();
    o.put("b1", b);
    o.put("b2", new Binary(BsonConstants.SUBTYPE_BINARY, b));
    o.put("uuid", new UUID(1L, 2L));

    Map<?, ?> data = parseBsonObject(o);
    assertEquals(3, data.size());/* ww w. j  a v a 2s .co  m*/
    assertArrayEquals(b, (byte[]) data.get("b1"));
    assertArrayEquals(b, (byte[]) data.get("b2"));
    assertEquals(new UUID(1L, 2L), data.get("uuid"));
}

From source file:aarddict.Volume.java

static UUID uuid(byte[] data) {
    long msb = 0;
    long lsb = 0;
    assert data.length == 16;
    for (int i = 0; i < 8; i++)
        msb = (msb << 8) | (data[i] & 0xff);
    for (int i = 8; i < 16; i++)
        lsb = (lsb << 8) | (data[i] & 0xff);
    return new UUID(msb, lsb);
}

From source file:com.joyent.manta.client.multipart.ServerSideMultipartManagerTest.java

public void canCreateCommitRequestBody() throws IOException {
    MantaMultipartUploadTuple[] unsortedTuples = new MantaMultipartUploadTuple[] {
            new MantaMultipartUploadTuple(5, new UUID(0L, 5L)),
            new MantaMultipartUploadTuple(3, new UUID(0L, 3L)),
            new MantaMultipartUploadTuple(1, new UUID(0L, 1L)),
            new MantaMultipartUploadTuple(2, new UUID(0L, 2L)),
            new MantaMultipartUploadTuple(4, new UUID(0L, 4L)) };

    Stream<MantaMultipartUploadTuple> partsStream = Arrays.stream(unsortedTuples);

    byte[] jsonRequest = ServerSideMultipartManager.createCommitRequestBody(partsStream).getLeft();

    ObjectNode objectNode = MantaObjectMapper.INSTANCE.readValue(jsonRequest, ObjectNode.class);
    @SuppressWarnings("unchecked")
    ArrayNode partsNode = (ArrayNode) objectNode.get("parts");

    // Verify that the parts are in the correct order
    try {/*from ww w .ja  v a  2 s . co m*/
        Assert.assertEquals(partsNode.get(0).textValue(), unsortedTuples[2].getEtag());
        Assert.assertEquals(partsNode.get(1).textValue(), unsortedTuples[3].getEtag());
        Assert.assertEquals(partsNode.get(2).textValue(), unsortedTuples[1].getEtag());
        Assert.assertEquals(partsNode.get(3).textValue(), unsortedTuples[4].getEtag());
        Assert.assertEquals(partsNode.get(4).textValue(), unsortedTuples[0].getEtag());
    } catch (AssertionError e) {
        System.err.println(new String(jsonRequest, StandardCharsets.UTF_8));
        throw e;
    }
}

From source file:io.selendroid.server.model.DefaultSelendroidDriver.java

@Override
public String initializeSession(JSONObject desiredCapabilities) {
    if (this.session != null) {
        session.getKnownElements().clear();
        return session.getSessionId();
    }/*w  w w  . j  av a  2 s .  c o  m*/
    activeWindowType = WindowType.NATIVE_APP.name();
    Random random = new Random();
    this.session = new Session(desiredCapabilities, new UUID(random.nextLong(), random.nextLong()).toString());
    nativeSearchScope = new NativeSearchScope(serverInstrumentation, getSession().getKnownElements());

    selendroidNativeDriver = new SelendroidNativeDriver(serverInstrumentation,
            (NativeSearchScope) nativeSearchScope);
    SelendroidLogger.info("new s: " + session.getSessionId());

    nativeExecuteScriptMap.put("invokeMenuActionSync", new InvokeMenuAction(session, serverInstrumentation));
    nativeExecuteScriptMap.put("findRId", new FindRId(serverInstrumentation));
    nativeExecuteScriptMap.put("getL10nKeyTranslation", new GetL10nKeyTranslation(serverInstrumentation));
    nativeExecuteScriptMap.put("findElementByAndroidTag",
            new FindElementByAndroidTag(session.getKnownElements(), serverInstrumentation, keySender));
    nativeExecuteScriptMap.put("isElementDisplayedInViewport",
            new IsElementDisplayedInViewport(session.getKnownElements(), serverInstrumentation));

    return session.getSessionId();
}

From source file:org.apache.hadoop.hbase.client.Mutation.java

/**
 * @return the set of clusterIds that have consumed the mutation
 */// w  ww .  j a  v a2 s.  c  om
public List<UUID> getClusterIds() {
    List<UUID> clusterIds = new ArrayList<UUID>();
    byte[] bytes = getAttribute(CONSUMED_CLUSTER_IDS);
    if (bytes != null) {
        ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
        int numClusters = in.readInt();
        for (int i = 0; i < numClusters; i++) {
            clusterIds.add(new UUID(in.readLong(), in.readLong()));
        }
    }
    return clusterIds;
}

From source file:info.archinnov.achilles.it.TestDSLEntityWithClusterings.java

@Test
public void should_dsl_update_multiple_partitions() throws Exception {
    //Given/*w  w  w .ja  v  a2 s  . c  o  m*/
    final Map<String, Object> values = new HashMap<>();
    final long id1 = RandomUtils.nextLong(0L, Long.MAX_VALUE);
    final long id2 = RandomUtils.nextLong(0L, Long.MAX_VALUE);
    values.put("id1", id1);
    values.put("id2", id1);
    values.put("id3", id1);
    values.put("id4", id2);
    values.put("id5", id2);

    final UUID uuid = new UUID(0L, 0L);

    values.put("uuid1", uuid);
    values.put("uuid2", uuid);
    values.put("uuid3", uuid);
    values.put("uuid4", uuid);
    values.put("uuid5", uuid);

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    final Date date1 = dateFormat.parse("2015-10-01 00:00:00 GMT");

    values.put("date1", "'2015-10-01 00:00:00+0000'");
    values.put("date2", "'2015-10-02 00:00:00+0000'");
    values.put("date3", "'2015-10-03 00:00:00+0000'");
    values.put("date4", "'2015-10-01 00:00:00+0000'");
    values.put("date5", "'2015-10-02 00:00:00+0000'");

    scriptExecutor.executeScriptTemplate("EntityWithClusteringColumns/insert_many_rows.cql", values);

    /*
    Data are ordered as:
            
    id1, uuid, date3,
    id1, uuid, date2,
    id1, uuid, date1,
    id2, uuid, date2,
    id2, uuid, date1
            
    because date is ORDERED BY DESC natively
     */

    //When
    manager.dsl().update().fromBaseTable().value_Set("new_value").where().id_IN(id1, id2).uuid_Eq(uuid)
            .date_Eq(date1).execute();

    //Then
    final List<Row> actuals = session.execute("SELECT value FROM entity_with_clusterings WHERE id IN (" + id1
            + "," + id2 + ") AND uuid = " + uuid + " AND date = '2015-10-01 00:00:00+0000'").all();

    assertThat(actuals).hasSize(2);
    assertThat(actuals.get(0).getString("value")).isEqualTo("new_value");
    assertThat(actuals.get(1).getString("value")).isEqualTo("new_value");
}

From source file:org.diorite.impl.command.defaults.DevCmd.java

public DevCmd() { // TODO: remove
    super("dev", Pattern.compile("(dev)(:(?<action>([a-z0-9_]*))|)", Pattern.CASE_INSENSITIVE),
            CommandPriority.LOW);//www.  j ava2s .  c o  m
    this.setDescription("Debug");
    this.setCommandExecutor((sender, command, label, matchedPattern, args) -> {
        final String action = matchedPattern.group("action");
        final IPlayer p = (IPlayer) sender;
        if (action == null) {
            p.getNetworkManager()
                    .sendPacket(new PacketPlayClientboundBlockChange(
                            args.readCoordinates(0, p.getLocation().toBlockLocation()), args.asInt(3),
                            args.asInt(4).byteValue()));
            return;
        }
        final IServerManager serverManager = DioriteCore.getInstance().getServerManager();
        final PermissionsManager mag = serverManager.getPermissionsManager();
        switch (action.toLowerCase()) {
        case "metadata": {
            final IEntity entity = p.getNearbyEntities(3, 3, 3, LookupShape.RECTANGLE).iterator().next();
            final int index = args.asInt(1);
            switch (args.asString(0)) {

            case "flag": {
                final String s = args.asString(2);
                for (final String flag : s.split(",")) {
                    entity.getMetadata().setBoolean(index, DioriteMathUtils.asInt(flag), args.asBoolean(3));
                }
                break;
            }
            case "int": {
                entity.getMetadata().setInt(index, args.asInt(2));
                break;
            }
            case "bool": {
                entity.getMetadata().setBoolean(index, args.asBoolean(2));
                break;
            }
            case "float": {
                entity.getMetadata().setFloat(index, args.asFloat(2));
                break;
            }
            case "loc": {
                entity.getMetadata().setBlockLocation(index,
                        args.readCoordinates(2, p.getLocation().toBlockLocation()));
                break;
            }
            }
            break;
        }
        case "mobname": {
            final IEntity entity = p.getNearbyEntities(3, 3, 3, LookupShape.RECTANGLE).iterator().next();
            System.out.println(args.asText());
            entity.setCustomName(
                    ChatColor.translateAlternateColorCodesInString(args.asText().replace("%n", "\n")));
            entity.setCustomNameVisible(true);
            break;
        }
        case "mob": {
            final IEntityFactory entityFactory = serverManager.getEntityFactory();
            if (args.asString(0).equalsIgnoreCase("creeper")) {
                final ICreeper creeper = entityFactory.createEntity(ICreeper.class, p.getLocation());
                creeper.getMetadata().setBoolean(ICreeper.META_KEY_CREEPER_POWERED, true);
                p.getWorld().addEntity(creeper);
            } else if (args.asString(0).equalsIgnoreCase("chickenArmy")) {
                DioriteCore.getInstance().sync(() -> {
                    for (double x = p.getX() - 10; x <= (p.getX() + 14); x += 1.5) {
                        for (double y = p.getY() - 6; y <= (p.getY() + 5); y += 1.5) {
                            for (double z = p.getZ() - 3; z <= (p.getZ() + 3); z += 1.5) {
                                final IChicken entity = entityFactory.createEntity(IChicken.class,
                                        new Location(x, y, z, p.getWorld()));
                                p.getWorld().addEntity(entity);
                            }
                        }
                    }
                }, p);
            } else if (args.asString(0).equalsIgnoreCase("zombie")) {
                final IZombie zombie = entityFactory.createEntity(IZombie.class, p.getLocation());
                zombie.setCustomName("Custom name!");
                zombie.setCustomNameVisible(true);
                //                        zombie.getMetadata().setInt(ILivingEntity.META_KEY_ARROWS_IN_BODY, args.has(1) ? args.asInt(1, 0) : 0);
                zombie.getMetadata().setInt(ILivingEntity.META_KEY_LIVING_POTION_EFFECT_COLOR,
                        args.has(1) ? Integer.parseInt(args.asString(1), 16) : 0);
                if (args.has(3)) {
                    String s = args.asString(2);
                    for (final String flag : s.split(",")) {
                        zombie.getMetadata().setBoolean(IEntity.META_KEY_ENTITY_BASIC_FLAGS,
                                DioriteMathUtils.asInt(flag), args.asBoolean(3));
                    }
                }
                zombie.setAir(-5);
                zombie.setSilent(true);
                p.getWorld().addEntity(zombie);
            } else if (args.asString(0).equalsIgnoreCase("area")) {
                final IAreaEffectCloud entity = entityFactory.createEntity(IAreaEffectCloud.class,
                        p.getLocation());
                entity.setColor(Color.AQUA);
                entity.setRadius(30);
                p.getWorld().addEntity(entity);
            } else if (args.asString(0).equalsIgnoreCase("area2")) {
                final IAreaEffectCloud entity = entityFactory.createEntity(IAreaEffectCloud.class,
                        p.getLocation());
                entity.getMetadata().setInt(IAreaEffectCloud.META_KEY_AREA_EFFECT_CLOUD_COLOR,
                        Integer.parseInt(args.asString(3), 16));
                entity.getMetadata().setFloat(IAreaEffectCloud.META_KEY_AREA_EFFECT_CLOUD_RADIUS,
                        args.asFloat(2));
                entity.getMetadata().setBoolean(IAreaEffectCloud.META_KEY_AREA_EFFECT_CLOUD_IS_POINT,
                        args.asBoolean(1));
                if (args.has(4)) {
                    Integer id = args.asInt(4);
                    if (id == null) {
                        id = Particle.getByParticleName(args.asString(4)).getParticleId();
                    }
                    entity.getMetadata().setInt(IAreaEffectCloud.META_KEY_AREA_EFFECT_CLOUD_PARTICLE_ID, id);
                }
                p.getWorld().addEntity(entity);
            } else if (args.asString(0).equalsIgnoreCase("crystal")) {
                final IEnderCrystal entity = entityFactory.createEntity(IEnderCrystal.class, p.getLocation());
                entity.getMetadata().setBoolean(IEnderCrystal.META_KEY_ENDER_CRYSTAL_SHOW_BOTTOM,
                        args.asBoolean(1));
                if (args.has(4)) {
                    entity.getMetadata().setBlockLocation(IEnderCrystal.META_KEY_ENDER_CRYSTAL_TARGET,
                            args.readCoordinates(2, p.getLocation().toBlockLocation()));
                }
                p.getWorld().addEntity(entity);
            } else {
                final IEntity entity = entityFactory.createEntity(EntityType.getByEnumName(args.asString(0)),
                        p.getLocation());
                if (entity != null) {
                    p.getWorld().addEntity(entity);
                }
            }
            break;
        }
        case "sound1": {
            p.getNetworkManager().sendPacket(
                    new PacketPlayClientboundSoundEffect(Sound.getById(args.asInt(0)), p.getLocation(), 2, 63));
            break;
        }
        case "sound2": {
            p.getNetworkManager().sendPacket(
                    new PacketPlayClientboundNamedSoundEffect(args.asString(0), p.getLocation(), 2, 63));
            break;
        }
        case "eq": {
            //                    Core
            break;
        }
        case "bookmeta": {
            final ItemStack item = new BaseItemStack(Material.WRITTEN_BOOK);
            final BookMeta meta = (BookMeta) item.getItemMeta();
            meta.setAuthor("Lel");
            meta.setPages("ugh");
            p.getInventory().add(item);
            break;
        }
        case "gib": {
            final ItemStack item = new BaseItemStack(Material.APPLE);
            item.setAmount(args.has(0) ? args.asInt(0, 1) : 1);
            final ItemMeta meta = item.getItemMeta();
            meta.setDisplayName("Diorite");
            p.getInventory().add(item);
            break;
        }
        case "potionmeta": {
            final ItemStack item = new BaseItemStack(
                    new PotionMat("POTION", 373, "minecraft:potion", 1, "POTION", (short) 8193, 5, 6) {
                    });
            final PotionMeta meta = new PotionMetaImpl(null);
            meta.addCustomEffect(new StatusEffect(StatusEffectType.INVISIBILITY, 3, 300, false, true), false);
            meta.addCustomEffect(new StatusEffect(StatusEffectType.INVISIBILITY, 3, 30000, false, true), false);
            item.setItemMeta(meta);
            p.getInventory().add(item);
            break;
        }
        case "m2": {
            final ItemMeta meta = p.getInventory().getItemInHand().getItemMeta();
            meta.setDisplayName(RandomStringUtils.randomAlphanumeric(16));
            break;
        }
        case "itemid": {
            final ItemMetaImpl meta = (ItemMetaImpl) p.getInventory().getItemInHand().getItemMeta();
            System.out.println("Meta: " + System.identityHashCode(meta) + ", tag: "
                    + (meta.getRawNbtData() == null ? "NULL"
                            : System.identityHashCode(meta.getRawNbtData()) + "")
                    + ", item: " + (!meta.getItemStack().isPresent() ? "NULL"
                            : System.identityHashCode(meta.getItemStack().get()) + ""));
            break;
        }
        case "skullmeta": {
            final ItemStack item = new BaseItemStack(SkullMat.SKULL_PLAYER);
            System.out.println(item.getItemMeta());
            final SkullMeta meta = (SkullMeta) item.getItemMeta();
            meta.setOwner(args.asString(0));
            System.out.println(meta);
            p.getInventory().add(item);
            break;
        }
        case "itemmeta": {
            final ItemStack item = new BaseItemStack(Material.STONE);
            final ItemMeta meta = item.getItemMeta();
            meta.setDisplayName("Custom name!");
            meta.setLore(Arrays.asList("North to", "gupi nup"));
            meta.addEnchant(EnchantmentType.AQUA_AFFINITY, 3, true);
            meta.addAttributeModifier(AttributeModifier.builder().setUuid(new UUID(0, 0)).setName("t")
                    .setValue(2.25D).setType(AttributeType.GENERIC_ATTACK_DAMAGE).build());
            meta.addAttributeModifier(AttributeModifier.builder().setUuid(new UUID(0, 1)).setName("t")
                    .setValue(2.25D).setType(AttributeType.GENERIC_MAX_HEALTH).build());
            p.getInventory().add(item);
            break;
        }
        case "pextest": {
            sender.setOp(false);
            mag.getPermissibleGroups(sender).forEach(g -> mag.removePermissibleFromGroup(sender, g));
            sender.sendMessage("Testing permissions: ");
            sender.sendMessage("foo.bar: " + sender.hasPermission("foo.bar")); // false
            sender.sendMessage("Your groups: " + mag.getPermissibleGroups(sender).stream()
                    .map(f -> f.getGroup().getName()).collect(Collectors.toList())); // empty
            final PermissionsGroup group = mag.createGroup("test");
            sender.sendMessage("Adding to group (" + group.getName() + "): "
                    + mag.addPermissibleToGroup(sender, group, 1)); // true
            sender.sendMessage("Your groups: " + mag.getPermissibleGroups(sender).stream()
                    .map(f -> f.getGroup().getName()).collect(Collectors.toList())); // test
            mag.setPermission(group, "foo.bar", PermissionLevel.TRUE);
            sender.sendMessage("foo.bar: " + sender.hasPermission("foo.bar")); // true
            mag.removePermissibleFromGroup(sender, "test");
            sender.sendMessage("Your groups: " + mag.getPermissibleGroups(sender).stream()
                    .map(f -> f.getGroup().getName()).collect(Collectors.toList())); // empty
            sender.sendMessage("foo.bar: " + sender.hasPermission("foo.bar")); // false
            sender.sendMessage("Adding to group (" + group.getName() + "): "
                    + mag.addPermissibleToGroup(sender, group, 1)); // true
            mag.setPermission(group, "foo.bar", PermissionLevel.OP);
            sender.sendMessage("foo.bar: " + sender.hasPermission("foo.bar")); // false
            sender.setOp(true);
            sender.sendMessage("foo.bar: " + sender.hasPermission("foo.bar")); // true
            sender.setOp(false);
            mag.setPermission(group, "foo.{$-$}", "foo.[-100--10,25-30]", PermissionLevel.TRUE); // from -100 to -10
            sender.sendMessage("foo.5: " + sender.hasPermission("foo.5")); // false
            sender.sendMessage("foo.-10: " + sender.hasPermission("foo.-10")); // true
            sender.sendMessage("foo.-25: " + sender.hasPermission("foo.-25")); // true
            sender.sendMessage("foo.25: " + sender.hasPermission("foo.25")); // true
            mag.removePermissibleFromGroup(sender, "test");
            sender.sendMessage("Your groups: " + mag.getPermissibleGroups(sender).stream()
                    .map(f -> f.getGroup().getName()).collect(Collectors.toList())); // empty
            sender.sendMessage("foo.5: " + sender.hasPermission("foo.5")); // false
            sender.sendMessage("foo.-10: " + sender.hasPermission("foo.-10")); // false
            sender.sendMessage("foo.-25: " + sender.hasPermission("foo.-25")); // false
            sender.sendMessage("foo.25: " + sender.hasPermission("foo.25")); // false
            sender.setOp(true);
            sender.sendMessage("foo.5: " + sender.hasPermission("foo.5")); // true
            sender.sendMessage("foo.-10: " + sender.hasPermission("foo.-10")); // true
            sender.sendMessage("foo.-25: " + sender.hasPermission("foo.-25")); // true
            sender.sendMessage("foo.25: " + sender.hasPermission("foo.25")); // true

            mag.addPermissibleToGroup(sender, mag.createGroup("test"), 1);
            mag.addPermissibleToGroup(sender, mag.createGroup("a1"), 2);
            mag.addPermissibleToGroup(sender, mag.createGroup("a2"), 3);
            mag.addPermissibleToGroup(sender, mag.createGroup("a3"), 4);
            sender.sendMessage("Your groups: " + mag.getPermissibleGroups(sender).stream()
                    .map(f -> f.getGroup().getName()).collect(Collectors.toList())); // test, a1, a2, a3
            mag.setPermission(mag.getGroup("test"), "test.test", PermissionLevel.FALSE);
            mag.setPermission(mag.getGroup("a3"), "test.test", PermissionLevel.TRUE);
            sender.sendMessage("test.test: " + sender.hasPermission("test.test")); // true
            mag.setPermission(sender, "test.test", PermissionLevel.NOT_OP);
            sender.sendMessage("test.test: " + sender.hasPermission("test.test")); // false
            mag.setPermission(mag.getGroup("a2"), "test.test2", PermissionLevel.FALSE);
            mag.setPermission(mag.getGroup("a1"), "test.test2", PermissionLevel.TRUE);
            sender.sendMessage("test.test2: " + sender.hasPermission("test.test2")); // false
            break;
        }
        case "pex": {
            if (sender.hasPermission(args.asString(0))) {
                sender.sendMessage("You have " + args.asString(0) + " permission!");
            } else {
                sender.sendMessage("You don't have " + args.asString(0) + " permission!");
            }
            break;
        }
        case "pexaddg": {
            final PermissionsGroup group = mag.getGroup(args.asString(0));
            if (group == null) {
                sender.sendMessage("No group, " + args.asString(0));
                return;
            }
            mag.setPermission(group, args.asString(1), args.asString(2).equalsIgnoreCase("null") ? null
                    : PermissionLevel.valueOf(args.asString(2).toUpperCase()));
            sender.sendMessage("Set permission " + args.asString(1) + ":"
                    + (args.asString(2).equalsIgnoreCase("null") ? null
                            : PermissionLevel.valueOf(args.asString(2).toUpperCase()))
                    + " to group " + group.getName());
            break;
        }
        case "pexadd": {
            mag.setPermission(sender, args.asString(0), args.asString(1).equalsIgnoreCase("null") ? null
                    : PermissionLevel.valueOf(args.asString(1).toUpperCase()));
            sender.sendMessage("Set permission " + args.asString(0) + ":"
                    + (args.asString(1).equalsIgnoreCase("null") ? null
                            : PermissionLevel.valueOf(args.asString(1).toUpperCase()))
                    + " to you");
            break;
        }
        case "pexaddu": {
            final boolean added = mag.addPermissibleToGroup(sender, args.asString(0), args.asInt(1));
            sender.sendMessage("Added you to " + args.asString(0) + " group: " + added);
            break;
        }
        case "pexreg": {
            mag.registerPermission(mag.createPermission(args.asString(0), args.asString(0),
                    PermissionLevel.valueOf(args.asString(1).toUpperCase())));
            sender.sendMessage("Register permission " + args.asString(0) + ":"
                    + PermissionLevel.valueOf(args.asString(1).toUpperCase()) + " to manager");
            break;
        }
        case "op": {
            if (p.isOp()) {
                p.setOp(false);
                sender.sendMessage("You are not op anymore...");
            } else {
                p.setOp(true);
                sender.sendMessage("You are now op!");
            }
            break;
        }
        case "pexrg": {
            final PermissionsGroup group = mag.removeGroup(args.asString(0));
            sender.sendMessage("Removed group: " + group);
            break;
        }
        case "pexcg": {
            final PermissionsGroup group = mag.createGroup(args.asString(0));
            sender.sendMessage("Created group: " + group);
            break;
        }
        case "setlocale": {
            p.setPreferedLocale((args.length() == 0) ? null : Locale.forLanguageTag(args.asText()));
            System.out.println("Done: " + p.getPreferredLocale());
            break;
        }
        case "msgr": {
            DioriteMessages.reload();
            System.out.println("Done");
            break;
        }
        case "msg": {
            p.setPreferedLocale(Locale.forLanguageTag("pl-PL"));
            DioriteMessages.broadcastMessage(args.asText(), MessageData.e("player", p),
                    MessageData.e("test", "Meeeh"));
            break;
        }
        case "tc": {
            final TextComponent tc = ComponentBuilder.start("test <r> ing").color(ChatColor.RED)
                    .event(new ClickEvent(Action.OPEN_URL, "www.diorite.org:<port>"))
                    .appendLegacy("2 costam costam 8<r> dbdjs fdd").create();
            sender.sendMessage(tc);
            System.out.println(tc.toLegacyText());
            System.out.println(ComponentSerializer.toString(tc));
            sender.sendMessage(tc.duplicate());
            System.out.println(tc.duplicate().toLegacyText());
            System.out.println(ComponentSerializer.toString(tc.duplicate()));
            break;
        }
        case "rep": {
            final TextComponent tc = ComponentBuilder.start("test <r> ing").color(ChatColor.RED)
                    .event(new ClickEvent(Action.OPEN_URL, "www.diorite.org:<port>"))
                    .appendLegacy("2 costam costam 8<r> dbdjs fdd").create();
            sender.sendMessage(tc.duplicate());
            tc.replace("<r>", ComponentBuilder.start("Replaced clickable text")
                    .event(new ClickEvent(Action.SUGGEST_COMMAND, "YeY")).create());
            tc.replace("<port>", new TextComponent("8081"));
            sender.sendMessage(tc);
            break;
        }
        case "inv": {
            ((InventoryHolder) sender).getInventory().update();
            sender.sendMessage("Inventory updated!");
            break;
        }
        case "gs": {
            p.getNetworkManager()
                    .sendPacket(new PacketPlayClientboundGameStateChange(args.asInt(0), args.asFloat(1)));
            sender.sendSimpleColoredMessage("&3Done.");
            break;
        }
        case "cb": {
            sender.sendSimpleColoredMessage(p.getLocation().toBlockLocation().getBlock().toString());
            break;
        }
        //                case "en":
        //                {
        //                    final ItemImpl item = new ItemImpl(UUID.randomUUID(), p.getCore(), IEntity.getNextEntityID(), p.getLocation().addX(3).addY(1));
        //                    item.setItemStack(new BaseItemStack(Material.TNT));
        //                    p.getWorld().addEntity(item);
        //                    break;
        //                }
        case "ep": {
            for (final IEntity e : p.getNearbyEntities(args.asDouble(0), args.asDouble(0), args.asDouble(0),
                    LookupShape.RECTANGLE)) {
                sender.sendSimpleColoredMessage("[" + e.getId() + "] " + e.getType() + ": " + e.getLocation());
            }
            break;
        }
        default: {
            sender.sendSimpleColoredMessage("&4No action...");
            break;
        }
        }
    });
}

From source file:com.alibaba.wasp.jdbc.TestPreparedStatement.java

public void testUUID() throws SQLException {
    Statement stat = conn.createStatement();
    stat.execute("create table test_uuid(id uuid primary key)");
    UUID uuid = new UUID(-2, -1);
    PreparedStatement prep = conn.prepareStatement("insert into test_uuid values(?)");
    prep.setObject(1, uuid);//  www.  j ava  2s  . c o  m
    prep.execute();
    ResultSet rs = stat.executeQuery("select * from test_uuid");
    rs.next();
    assertEquals("ffffffff-ffff-fffe-ffff-ffffffffffff", rs.getString(1));
    Object o = rs.getObject(1);
    assertEquals("java.util.UUID", o.getClass().getName());
    stat.execute("drop table test_uuid");
}