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


Java Profile类代码示例

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


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

示例1: findAllByName

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Override
public void findAllByName(Iterable<String> names, final Predicate<Profile> consumer) throws IOException, InterruptedException {
    final List<String> missing = Collections.synchronizedList(new ArrayList<String>());

    Predicate<Profile> forwardingConsumer = new Predicate<Profile>() {
        @Override
        public boolean apply(Profile profile) {
            missing.remove(profile.getName().toLowerCase());
            return consumer.apply(profile);
        }
    };

    for (String name : names) {
        missing.add(name.toLowerCase());
    }

    for (ProfileService service : services) {
        service.findAllByName(new ArrayList<String>(missing), forwardingConsumer);

        if (missing.isEmpty()) {
            break;
        }
    }
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:25,代码来源:CombinedProfileService.java

示例2: putAll

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Override
public void putAll(Iterable<Profile> iterable) {
  try {
    executePut(iterable);
  } catch (SQLException e) {
    CMain.getLogger().log(Level.WARNING, "Failed to execute queries", e);
  }
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:9,代码来源:MySQLCache.java

示例3: getAllPresent

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Override
public ImmutableMap<UUID, Profile> getAllPresent(Iterable<UUID> iterable) {
  try {
    return executeGet(iterable);
  } catch (SQLException e) {
    CMain.getLogger().log(Level.WARNING, "Failed to execute queries", e);
  }

  return ImmutableMap.of();
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:11,代码来源:MySQLCache.java

示例4: executePut

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
protected synchronized void executePut(Iterable<Profile> profiles) throws SQLException {
  PreparedStatement stmt = preparedStatement();
  for (Profile profile : profiles) {
    stmt.setString(1, profile.getUniqueId().toString());
    stmt.setString(2, profile.getName());
    stmt.addBatch();
  }
  stmt.executeBatch();
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:10,代码来源:MySQLCache.java

示例5: executeGet

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
protected ImmutableMap<UUID, Profile> executeGet(Iterable<UUID> uuids) throws SQLException {
  Iterator<UUID> it = uuids.iterator();
  // It was an empty collection
  if (!it.hasNext()) {
    return ImmutableMap.of();
  }

  StringBuilder builder = new StringBuilder();
  // SELECT ... WHERE ... IN ('abc', 'def', 'ghi');
  builder.append("SELECT name, uuid FROM `").append(this.tableName).append("` WHERE uuid IN ('");
  Joiner.on("', '").skipNulls().appendTo(builder, uuids);
  builder.append("');");

  synchronized (this) {
    try (Connection conn = getConnection();
         Statement stmt = conn.createStatement()) {
      ResultSet rs = stmt.executeQuery(builder.toString());
      Map<UUID, Profile> map = new HashMap<>();

      while (rs.next()) {
        UUID uuid = UUID.fromString(rs.getString("uuid"));
        map.put(uuid, new Profile(uuid, rs.getString("name")));
      }

      return ImmutableMap.copyOf(map);
    }
  }
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:29,代码来源:MySQLCache.java

示例6: getAllPresent

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Override
public ImmutableMap<UUID, Profile> getAllPresent(Iterable<UUID> uuids) {
    Map<UUID, Profile> results = new HashMap<UUID, Profile>();
    for (UUID uuid : uuids) {
        String name = cache.get(uuid);
        if (name != null) {
            results.put(uuid, new Profile(uuid, name));
        }
    }
    return ImmutableMap.copyOf(results);
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:12,代码来源:HashMapCache.java

示例7: putAll

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Override
public void putAll(Iterable<Profile> entries) {
    try {
        executePut(entries);
    } catch (SQLException e) {
        log.log(Level.WARNING, "Failed to execute queries", e);
    }
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:9,代码来源:SQLiteCache.java

示例8: getAllPresent

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Override
public ImmutableMap<UUID, Profile> getAllPresent(Iterable<UUID> uuids) {
    try {
        return executeGet(uuids);
    } catch (SQLException e) {
        log.log(Level.WARNING, "Failed to execute queries", e);
    }

    return ImmutableMap.of();
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:11,代码来源:SQLiteCache.java

示例9: executePut

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
protected synchronized void executePut(Iterable<Profile> profiles) throws SQLException {
    for (Profile profile : profiles) {
        updateStatement.setString(1, profile.getUniqueId().toString());
        updateStatement.setString(2, profile.getName());
        updateStatement.executeUpdate();
    }
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:8,代码来源:SQLiteCache.java

示例10: executeGet

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
protected ImmutableMap<UUID, Profile> executeGet(Iterable<UUID> uuids) throws SQLException {
    StringBuilder builder = new StringBuilder();
    builder.append("SELECT name, uuid FROM uuid_cache WHERE uuid IN (");

    boolean first = true;
    for (UUID uuid : uuids) {
        checkNotNull(uuid, "Unexpected null UUID");
        
        if (!first) {
            builder.append(", ");
        }
        builder.append("'").append(uuid).append("'");
        first = false;
    }

    // It was an empty collection
    if (first) {
        return ImmutableMap.of();
    }

    builder.append(")");

    synchronized (this) {
        Connection conn = getConnection();
        Statement stmt = conn.createStatement();
        try {
            ResultSet rs = stmt.executeQuery(builder.toString());
            Map<UUID, Profile> map = new HashMap<UUID, Profile>();

            while (rs.next()) {
                UUID uniqueId = UUID.fromString(rs.getString("uuid"));
                map.put(uniqueId, new Profile(uniqueId, rs.getString("name")));
            }

            return ImmutableMap.copyOf(map);
        } finally {
            stmt.close();
        }
    }
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:41,代码来源:SQLiteCache.java

示例11: findByName

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Nullable
@Override
public Profile findByName(String name) throws IOException, InterruptedException {
    ImmutableList<Profile> profiles = findAllByName(Arrays.asList(name));
    if (!profiles.isEmpty()) {
        return profiles.get(0);
    } else {
        return null;
    }
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:11,代码来源:HttpRepositoryService.java

示例12: findAllByName

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Override
public void findAllByName(Iterable<String> names, Predicate<Profile> consumer) throws IOException, InterruptedException {
    for (List<String> partition : Iterables.partition(names, MAX_NAMES_PER_REQUEST)) {
        for (Profile profile : query(partition)) {
            consumer.apply(profile);
        }
    }
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:9,代码来源:HttpRepositoryService.java

示例13: findByName

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Nullable
@Override
public Profile findByName(String name) throws IOException, InterruptedException {
    Profile profile = resolver.findByName(name);
    if (profile != null) {
        cache.put(profile);
    }
    return profile;
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:10,代码来源:CacheForwardingService.java

示例14: findAllByName

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Override
public ImmutableList<Profile> findAllByName(Iterable<String> names) throws IOException, InterruptedException {
    ImmutableList<Profile> profiles = resolver.findAllByName(names);
    for (Profile profile : profiles) {
        cache.put(profile);
    }
    return profiles;
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:9,代码来源:CacheForwardingService.java

示例15: findByName

import com.sk89q.squirrelid.Profile; //导入依赖的package包/类
@Nullable
@Override
public Profile findByName(String name) throws IOException, InterruptedException {
    for (ProfileService service : services) {
        Profile profile = service.findByName(name);
        if (profile != null) {
            return profile;
        }
    }
    return null;
}
 
开发者ID:EngineHub,项目名称:SquirrelID,代码行数:12,代码来源:CombinedProfileService.java


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