com.wizzardo.tools.misc.Unchecked类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中com.wizzardo.tools.misc.Unchecked类的一些代码示例,展示了Unchecked类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unchecked类的具体详情如下:
包路径:com.wizzardo.tools.misc.Unchecked
类名称:Unchecked

Unchecked介绍

暂无

代码示例

代码示例来源:origin: com.wizzardo.tools/tools-evaluation

@Override
  public void set(Object instance, Object value) {
    try {
      method.invoke(instance, value);
    } catch (IllegalAccessException e) {
      throw Unchecked.rethrow(e);
    } catch (InvocationTargetException e) {
      throw Unchecked.rethrow(e);
    }
  }
}

代码示例来源:origin: com.wizzardo.tools/tools-misc

protected T init() {
  return Unchecked.call(supplier);
}

代码示例来源:origin: wizzardo/tools

public static void run(UncheckedRunnable runnable) {
  run(runnable, null);
}

代码示例来源:origin: wizzardo/http

public T getRaw(Map<String, Object> model) {
  if (!prepared) {
    synchronized (this) {
      if (!prepared) {
        Unchecked.run(() -> {
          if (stringTemplate)
            expression = EvalTools.prepare(string, model, TagLib.getTagFunctions(), imports, true);
          else {
            Matcher m = p.matcher(string);
            if (m.matches()) {
              String exp = m.group(1);
              if (exp == null) {
                exp = m.group(2);
              }
              if (exp == null) {
                exp = m.group(3);
              }
              expression = EvalTools.prepare(exp, model, TagLib.getTagFunctions(), imports);
            } else
              expression = EvalTools.prepare(string, model, TagLib.getTagFunctions(), imports);
          }
          setVariables(expression);
        });
        prepared = true;
      }
    }
  }
  return Unchecked.call(() -> (T) expression.get(model));
}

代码示例来源:origin: wizzardo/tools

public static <T> T ignore(Callable<T> callable) {
  return ignore(callable, null);
}

代码示例来源:origin: wizzardo/http

protected void loadManifest(Config config) {
  Unchecked.ignore(() -> {
    Manifest manifest = new Manifest(WebApplication.class.getResourceAsStream("/META-INF/MANIFEST.MF"));
    Config subconfig = config.config("manifest");
    manifest.getMainAttributes().forEach((k, v) -> putInto(subconfig, String.valueOf(k), String.valueOf(v)));
  });
}

代码示例来源:origin: wizzardo/tools

private static Object createInstance(Constructor c) {
  try {
    return c.newInstance();
  } catch (IllegalAccessException e) {
    throw Unchecked.rethrow(e);
  } catch (InstantiationException e) {
    throw Unchecked.rethrow(e);
  } catch (InvocationTargetException e) {
    throw Unchecked.rethrow(e);
  }
}

代码示例来源:origin: wizzardo/http

protected String getCanonicalPath(File file) {
  return Unchecked.call(file::getCanonicalPath);
}

代码示例来源:origin: wizzardo/http

@Override
  public void onComplete() {
    Unchecked.run(() -> ProxyConnection.this.onRead((ByteBufferProvider) Thread.currentThread()));
  }
}

代码示例来源:origin: wizzardo/http

public String getResourceAsString(String path) {
  return Unchecked.ignore(() -> new String(IOTools.bytes(getResource(path)), StandardCharsets.UTF_8));
}

代码示例来源:origin: com.wizzardo.tools/tools-evaluation

@Override
  public Object get(Object instance) {
    try {
      return method.invoke(instance);
    } catch (IllegalAccessException e) {
      throw Unchecked.rethrow(e);
    } catch (InvocationTargetException e) {
      throw Unchecked.rethrow(e);
    }
  }
}

代码示例来源:origin: wizzardo/tools

public static <T> T call(Callable<T> callable) {
  return call(callable, null);
}

代码示例来源:origin: wizzardo/http

public PropertiesMessageSource(String name, ResourceTools resourcesTools) {
    Properties properties = new Properties();
    Unchecked.run(() -> properties.load(resourcesTools.getResource("/i18n/" + name + ".properties")));

    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
      templates.put(String.valueOf(entry.getKey()), new Template(String.valueOf(entry.getValue())));
    }
  }
}

代码示例来源:origin: com.wizzardo.tools/tools-evaluation

protected <T> T creteInstance(Class<T> clazz) {
  T t;
  try {
    t = clazz.newInstance();
  } catch (InstantiationException e) {
    throw Unchecked.rethrow(e);
  } catch (IllegalAccessException e) {
    throw Unchecked.rethrow(e);
  }
  return t;
}

代码示例来源:origin: wizzardo/tools

protected T init() {
  return Unchecked.call(supplier);
}

代码示例来源:origin: wizzardo/http

protected void checkResponse(int status, String message, com.wizzardo.tools.http.Response response) {
  Unchecked.run(() -> {
    Assert.assertEquals(status, response.getResponseCode());
    Assert.assertEquals(message, response.asString());
  });
}

代码示例来源:origin: wizzardo/tools

@Override
  public void set(Object instance, Object value) {
    try {
      method.invoke(instance, value);
    } catch (IllegalAccessException e) {
      throw Unchecked.rethrow(e);
    } catch (InvocationTargetException e) {
      throw Unchecked.rethrow(e);
    }
  }
}

代码示例来源:origin: wizzardo/http

public static Tag createTag(String name) {
  Class<? extends Tag> c = taglib.get(name);
  if (c == null)
    return null;
  return Unchecked.call(c::newInstance);
}

代码示例来源:origin: wizzardo/http

response.commit(request.connection());
  request.connection().flush();
  Unchecked.run(() -> request.connection().onFinishingHandling());
});
return response;

代码示例来源:origin: wizzardo/tools

protected <T> T creteInstance(Class<T> clazz) {
  T t;
  try {
    t = clazz.newInstance();
  } catch (InstantiationException e) {
    throw Unchecked.rethrow(e);
  } catch (IllegalAccessException e) {
    throw Unchecked.rethrow(e);
  }
  return t;
}

相关文章