本文整理汇总了Java中com.google.gag.annotation.remark.Hack类的典型用法代码示例。如果您正苦于以下问题:Java Hack类的具体用法?Java Hack怎么用?Java Hack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hack类属于com.google.gag.annotation.remark包,在下文中一共展示了Hack类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: login
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@Hack
@SubscribeEvent
public void login(PlayerLoggedInEvent e)
{
if (e.player.worldObj.isRemote)
{
// do nothing on client
return;
}
Collection<BloodStain> outStains = getStains(e.player.dimension);
System.out.println("SENDING STAIONS: " + outStains.size());
for (BloodStain stain : outStains)
{
PacketManager.sendToPlayer(new PacketCreateStain(stain), e.player);
}
}
示例2: dimChange
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@Hack
@Metaphor
@SubscribeEvent
public void dimChange(PlayerChangedDimensionEvent e)
{
if (e.player.worldObj.isRemote)
{
// server only.
return;
}
// old stain remover
PacketManager.sendToPlayer(new PacketStainRemover(e.fromDim), e.player);
// send new stains
Collection<BloodStain> outStains = removeStains(e.toDim);
for (BloodStain stain : outStains)
{
PacketManager.sendToPlayer(new PacketCreateStain(stain), e.player);
}
}
示例3: defer
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@Hack
@OhNoYouDidnt
private static Optional<Plugin> defer(final ListableBeanFactory factory, final String typeName) {
return Optional.of(typeName)
.filter(DefaultPluginResolver::exists)
.map(throwingFunction(DefaultPluginResolver::forName))
.map(type -> defer(factory, type));
}
示例4: getConfiguration
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@Hack
private TokenRefresherConfiguration getConfiguration() throws NoSuchFieldException, IllegalAccessException {
final Class<? extends AccessTokens> type = accessTokens.getClass();
final Field field = type.getSuperclass().getDeclaredField("configuration");
field.setAccessible(true);
return (TokenRefresherConfiguration) field.get(accessTokens);
}
示例5: negotiate
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@SneakyThrows(HttpMediaTypeNotAcceptableException.class)
default Optional<MediaType> negotiate(final NativeWebRequest request) {
final HeaderContentNegotiationStrategy negotiator = new HeaderContentNegotiationStrategy();
final List<MediaType> mediaTypes = negotiator.resolveMediaTypes(request);
if (mediaTypes.isEmpty()) {
return Optional.of(PROBLEM);
}
for (final MediaType mediaType : mediaTypes) {
if (mediaType.includes(APPLICATION_JSON) || mediaType.includes(PROBLEM)) {
return Optional.of(PROBLEM);
} else if (mediaType.includes(X_PROBLEM)) {
return Optional.of(X_PROBLEM);
}
}
@Hack("Accepting application/something+json doesn't make you understand application/problem+json, " +
"but a lot of clients miss to send it correctly")
final boolean isNeitherAcceptingJsonNorProblemJsonButSomeVendorSpecificJson =
mediaTypes.stream().anyMatch(WILDCARD_JSON::includes);
if (isNeitherAcceptingJsonNorProblemJsonButSomeVendorSpecificJson) {
return Optional.of(PROBLEM);
}
return Optional.empty();
}
示例6: validRequestParam
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@RequestMapping(path = "/handler-invalid-param", method = POST)
public void validRequestParam(@RequestBody final UserRequest user) {
@Hack("I couldn't make Spring throw this implicitly using annotations...")
@Facepalm
@OhNoYouDidnt
final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
final Set<ConstraintViolation<UserRequest>> violations = validator.validate(user);
throw new ConstraintViolationException(violations);
}
示例7: specificJsonGivesProblem
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@Test
@Hack("This is actually rather shady, but it's most likely what the client actually wants")
public void specificJsonGivesProblem() throws Exception {
mvc().perform(request(GET, url)
.accept("application/x.vendor.specific+json"))
.andExpect(content().contentType(MediaTypes.PROBLEM));
}
示例8: extractCharset
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@Hack("MediaType#getCharset is not available prior to Spring 4.3")
@SuppressWarnings("deprecation")
private static Charset extractCharset(final MediaType mediaType) {
return mediaType.getCharSet();
}
示例9: getReasonPhrase
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
@Hack("Because several status codes are defined with different reason phrases in Spring and JAX-RS")
private String getReasonPhrase(final Status status) {
return HttpStatus.valueOf(status.getStatusCode()).getReasonPhrase();
}
示例10: set
import com.google.gag.annotation.remark.Hack; //导入依赖的package包/类
/**
* This is required to workaround missing support for {@link com.fasterxml.jackson.annotation.JsonAnySetter} on
* constructors annotated with {@link com.fasterxml.jackson.annotation.JsonCreator}.
*
* @param key the custom key
* @param value the custom value
* @see <a href="https://github.com/FasterXML/jackson-databind/issues/562">Jackson Issue 562</a>
*/
@Hack
@OhNoYouDidnt
void set(final String key, final Object value) {
parameters.put(key, value);
}