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


Java CheckReturnValue类代码示例

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


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

示例1: getMessageById

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
@CheckReturnValue
public RestAction<MessageJson> getMessageById(long channelId, long messageId)
{
    Route.CompiledRoute route = Route.Messages.GET_MESSAGE.compile(Long.toString(channelId), Long.toString(messageId));
    return new RestAction<MessageJson>(fakeJDA, route)
    {
        @Override
        protected void handleResponse(Response response, Request<MessageJson> request)
        {
            if (response.isOk())
                request.onSuccess(new MessageJson(response.getObject()));
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:jagrosh,项目名称:GiveawayBot,代码行数:17,代码来源:RestJDA.java

示例2: of

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
/**
 * Creates a new {@link Scheme} instance.
 *
 * @param n the number of parts to produce (must be {@code >1})
 * @param k the threshold of joinable parts (must be {@code <= n})
 * @return an {@code N}/{@code K} {@link Scheme}
 */
@CheckReturnValue
public static Scheme of(@Nonnegative int n, @Nonnegative int k) {
  checkArgument(k > 1, "K must be > 1");
  checkArgument(n >= k, "N must be >= K");
  checkArgument(n <= 255, "N must be <= 255");
  return new AutoValue_Scheme(n, k);
}
 
开发者ID:codahale,项目名称:shamir,代码行数:15,代码来源:Scheme.java

示例3: split

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
/**
 * Splits the given secret into {@code n} parts, of which any {@code k} or more can be combined to
 * recover the original secret.
 *
 * @param secret the secret to split
 * @return a map of {@code n} part IDs and their values
 */
@CheckReturnValue
public Map<Integer, byte[]> split(byte[] secret) {
  // generate part values
  final byte[][] values = new byte[n()][secret.length];
  for (int i = 0; i < secret.length; i++) {
    // for each byte, generate a random polynomial, p
    final byte[] p = GF256.generate(random, k() - 1, secret[i]);
    for (int x = 1; x <= n(); x++) {
      // each part's byte is p(partId)
      values[x - 1][i] = GF256.eval(p, (byte) x);
    }
  }

  // return as a set of objects
  final Map<Integer, byte[]> parts = new HashMap<>(n());
  for (int i = 0; i < values.length; i++) {
    parts.put(i + 1, values[i]);
  }
  return Collections.unmodifiableMap(parts);
}
 
开发者ID:codahale,项目名称:shamir,代码行数:28,代码来源:Scheme.java

示例4: canRunDJAction

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
@CheckReturnValue
public static boolean canRunDJAction(AvaIre avaire, Message message, DJGuildLevel level) {
    GuildTransformer transformer = GuildController.fetchGuild(avaire, message);

    if (transformer == null) {
        return level.getLevel() <= DJGuildLevel.getNormal().getLevel();
    }

    DJGuildLevel guildLevel = transformer.getDJLevel();
    if (guildLevel == null) {
        guildLevel = DJGuildLevel.getNormal();
    }

    switch (guildLevel) {
        case ALL:
            return true;

        case NONE:
            return hasDJRole(message);

        default:
            return hasDJRole(message) || level.getLevel() < guildLevel.getLevel();
    }
}
 
开发者ID:avaire,项目名称:avaire,代码行数:25,代码来源:AudioHandler.java

示例5: connectToVoiceChannel

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
@CheckReturnValue
public static VoiceConnectStatus connectToVoiceChannel(Message message, boolean moveChannelIfConnected) {
    AudioManager audioManager = message.getGuild().getAudioManager();
    if (!audioManager.isAttemptingToConnect()) {
        VoiceChannel channel = message.getMember().getVoiceState().getChannel();
        if (channel == null) {
            return VoiceConnectStatus.NOT_CONNECTED;
        }

        if (audioManager.isConnected()) {
            if (channel.getIdLong() == audioManager.getConnectedChannel().getIdLong()) {
                return VoiceConnectStatus.CONNECTED;
            }

            if (moveChannelIfConnected) {
                return connectToVoiceChannel(message, channel, audioManager);
            }
            return VoiceConnectStatus.CONNECTED;
        }
        return connectToVoiceChannel(message, channel, audioManager);
    }
    return VoiceConnectStatus.CONNECTED;
}
 
开发者ID:avaire,项目名称:avaire,代码行数:24,代码来源:AudioHandler.java

示例6: selectJpqlQuerySingleResult

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
/**
 * Use this for COUNT() and similar jpql queries which are guaranteed to return a result
 */
@Nonnull
@CheckReturnValue
public <T> T selectJpqlQuerySingleResult(@Nonnull final String queryString,
                                         @Nullable final Map<String, Object> parameters,
                                         @Nonnull final Class<T> resultClass) throws DatabaseException {
    final EntityManager em = this.databaseConnection.getEntityManager();
    try {
        final Query q = em.createQuery(queryString);
        if (parameters != null) {
            parameters.forEach(q::setParameter);
        }
        em.getTransaction().begin();
        final T result = resultClass.cast(q.getSingleResult());
        em.getTransaction().commit();
        return setSauce(result);
    } catch (final PersistenceException | ClassCastException e) {
        final String message = String.format("Failed to select single result JPQL query %s with %s parameters for class %s on DB %s",
                queryString, parameters != null ? parameters.size() : "null", resultClass.getName(), this.databaseConnection.getName());
        throw new DatabaseException(message, e);
    } finally {
        em.close();
    }
}
 
开发者ID:napstr,项目名称:SqlSauce,代码行数:27,代码来源:DatabaseWrapper.java

示例7: isAvailable

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
@CheckReturnValue
@VisibleForTesting
@SuppressWarnings("WeakerAccess")
static boolean isAvailable(@Nonnull AnActionEvent event) {
    final Project project = event.getProject();
    if (project == null) {
        return false;
    }

    final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
    if (view == null) {
        return false;
    }

    final ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
    final ProjectFileIndex fileIndex = rootManager.getFileIndex();
    final Optional<PsiDirectory> sourceDirectory = Stream.of(view.getDirectories())
            .filter(directory -> {
                final VirtualFile virtualFile = directory.getVirtualFile();
                return fileIndex.isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.SOURCES);
            })
            .findFirst();
    return sourceDirectory.isPresent();
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:25,代码来源:NewClassAction.java

示例8: getEntity

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
/**
 * @return An entity if it exists in the database or null if it doesn't exist. If the entity is a SaucedEntity the
 * sauce will be set.
 */
@Nullable
@CheckReturnValue
public <E extends IEntity<I, E>, I extends Serializable> E getEntity(@Nonnull final EntityKey<I, E> entityKey)
        throws DatabaseException {
    final EntityManager em = this.databaseConnection.getEntityManager();
    try {
        em.getTransaction().begin();
        @Nullable final E result = em.find(entityKey.clazz, entityKey.id);
        em.getTransaction().commit();
        return setSauce(result);
    } catch (final PersistenceException e) {
        final String message = String.format("Failed to find entity of class %s for id %s on DB %s",
                entityKey.clazz.getName(), entityKey.id.toString(), this.databaseConnection.getName());
        throw new DatabaseException(message, e);
    } finally {
        em.close();
    }
}
 
开发者ID:napstr,项目名称:SqlSauce,代码行数:23,代码来源:DatabaseWrapper.java

示例9: runTestQuery

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
/**
 * @return true if the test query was successful and false if not
 */
@CheckReturnValue
public boolean runTestQuery() {
    final EntityManager em = this.emf.createEntityManager();
    try {
        em.getTransaction().begin();
        em.createNativeQuery(TEST_QUERY).getResultList();
        em.getTransaction().commit();
        return true;
    } catch (final PersistenceException e) {
        log.error("Test query failed", e);
        return false;
    } finally {
        em.close();
    }
}
 
开发者ID:napstr,项目名称:SqlSauce,代码行数:19,代码来源:DatabaseConnection.java

示例10: persist

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
/**
 * The difference of persisting to merging is that persisting will throw an exception if the entity exists already.
 *
 * @return The managed version of the provided entity (with set autogenerated values for example).
 */
@Nonnull
@CheckReturnValue
//returns whatever was passed in, with a sauce if it was a sauced entity
public <E> E persist(@Nonnull final E entity) throws DatabaseException {
    final EntityManager em = this.databaseConnection.getEntityManager();
    try {
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        return setSauce(entity);
    } catch (final PersistenceException e) {
        final String message = String.format("Failed to persist entity %s on DB %s",
                entity.toString(), this.databaseConnection.getName());
        throw new DatabaseException(message, e);
    } finally {
        em.close();
    }
}
 
开发者ID:napstr,项目名称:SqlSauce,代码行数:24,代码来源:DatabaseWrapper.java

示例11: build

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
@Nonnull
@CheckReturnValue
public DatabaseConnection build() throws DatabaseException {
    return new DatabaseConnection(
            this.dbName,
            this.jdbcUrl,
            this.dataSourceProps,
            this.hikariConfig,
            this.hibernateProps,
            this.entityPackages,
            this.poolName,
            this.sshDetails,
            this.hikariStats,
            this.hibernateStats,
            this.checkConnection,
            this.proxyDataSourceBuilder,
            this.flyway
    );
}
 
开发者ID:napstr,项目名称:SqlSauce,代码行数:20,代码来源:DatabaseConnection.java

示例12: open

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
/**
 * Decrypts the given encrypted message.
 *
 * @param nonce the 12-byte random nonce used to encrypt the message
 * @param ciphertext the returned value from {@link #seal(byte[], byte[], byte[])}
 * @param data the authenticated data used to encrypt the message (may be empty)
 * @return the plaintext message
 */
@CheckReturnValue
public Optional<byte[]> open(byte[] nonce, byte[] ciphertext, byte[] data) {
  if (nonce.length != NONCE_SIZE) {
    throw new IllegalArgumentException("Nonce must be 12 bytes long");
  }

  final byte[] c = new byte[ciphertext.length - AES_BLOCK_SIZE];
  final byte[] tag = new byte[AES_BLOCK_SIZE];
  System.arraycopy(ciphertext, 0, c, 0, c.length);
  System.arraycopy(ciphertext, c.length, tag, 0, tag.length);

  final byte[] authKey = subKey(0, 1, nonce);
  final Cipher encAES = newAES(subKey(2, aes128 ? 3 : 5, nonce));
  aesCTR(encAES, tag, c, c);
  final byte[] actual = hash(encAES, authKey, nonce, c, data);

  if (MessageDigest.isEqual(tag, actual)) {
    return Optional.of(c);
  }
  return Optional.empty();
}
 
开发者ID:codahale,项目名称:aes-gcm-siv,代码行数:30,代码来源:AEAD.java

示例13: afterInvocation

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
@Override
@CheckReturnValue
public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) {
    if (method.isTestMethod()) {
        final String fileName = String.format("http://localhost:4444/video/%s.mp4",
                testResult.getAttribute("sessionId"));
        attachUri("Video", fileName);
    }
}
 
开发者ID:sskorol,项目名称:qaa-amazon,代码行数:10,代码来源:VideoRecordingListener.java

示例14: editMessage

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
@CheckReturnValue
public MessageAction editMessage(long channelId, long messageId, Message newContent)
{
    Checks.notNull(newContent, "message");
    Route.CompiledRoute route = Route.Messages.EDIT_MESSAGE.compile(Long.toString(channelId), Long.toString(messageId));
    return new MessageAction(fakeJDA, route, new TextChannelImpl(channelId, new GuildImpl(fakeJDA, 0))).apply(newContent);
}
 
开发者ID:jagrosh,项目名称:GiveawayBot,代码行数:8,代码来源:RestJDA.java

示例15: sendMessage

import javax.annotation.CheckReturnValue; //导入依赖的package包/类
@CheckReturnValue
public MessageAction sendMessage(long channelId, Message msg)
{
    Checks.notNull(msg, "Message");
    Route.CompiledRoute route = Route.Messages.SEND_MESSAGE.compile(Long.toString(channelId));
    return new MessageAction(fakeJDA, route, new TextChannelImpl(channelId, new GuildImpl(fakeJDA, 0))).apply(msg);
}
 
开发者ID:jagrosh,项目名称:GiveawayBot,代码行数:8,代码来源:RestJDA.java


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