本文整理汇总了Java中org.osgl.util.C类的典型用法代码示例。如果您正苦于以下问题:Java C类的具体用法?Java C怎么用?Java C使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
C类属于org.osgl.util包,在下文中一共展示了C类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: managedFields
import org.osgl.util.C; //导入依赖的package包/类
public List<String> managedFields(String className) {
List<String> fields = managedFieldByClass.get(className);
if (null == fields) {
fields = C.newList();
Set<String> ss = storageFields();
for (String s: ss) {
if (s.startsWith(className + ":")) {
String fn = S.after(s, ":");
if (S.notEmpty(fn)) {
fields.add(fn);
}
}
}
managedFieldByClass.put(className, fields);
}
return fields;
}
示例2: initService
import org.osgl.util.C; //导入依赖的package包/类
private void initService(String ssId, Map<String, String> conf) {
Map<String, String> svcConf = C.newMap();
String prefix = "ss." + (S.empty(ssId) ? "" : ssId + ".");
for (String key : conf.keySet()) {
if (key.startsWith(prefix)) {
String o = conf.get(key);
svcConf.put(key.substring(prefix.length()), o);
}
}
String impl = svcConf.remove("impl");
String svcId = S.empty(ssId) ? DEFAULT : ssId;
if (null == impl) {
throw new ConfigurationException("Cannot init storage service[%s]: implementation not specified", svcId);
}
StoragePlugin plugin = StoragePluginManager.instance().plugin(impl);
if (null == plugin) {
throw new ConfigurationException("Cannot init storage service[%s]: implementation not found", svcId);
}
svcConf.put(IStorageService.CONF_ID, "".equals(ssId) ? DEFAULT : ssId);
IStorageService svc = plugin.initStorageService(ssId, app(), svcConf);
serviceById.put(svcId, svc);
logger.info("storage service[%s] initialized", svcId);
}
示例3: registerFactoryMethod
import org.osgl.util.C; //导入依赖的package包/类
private void registerFactoryMethod(final Object instance, final Method factory) {
Type retType = factory.getGenericReturnType();
Annotation[] factoryAnnotations = factory.getAnnotations();
final BeanSpec spec = BeanSpec.of(retType, factoryAnnotations, this);
final MethodInjector methodInjector = methodInjector(factory, C.<BeanSpec>empty());
addIntoRegistry(spec, decorate(spec, new Provider() {
@Override
public Object get() {
return methodInjector.applyTo(instance);
}
@Override
public String toString() {
return S.fmt("%s::%s", instance.getClass().getName(), methodInjector.method.getName());
}
}, true), factoryAnnotations.length == 0);
fireProviderRegisteredEvent(spec.rawType());
}
示例4: toString
import org.osgl.util.C; //导入依赖的package包/类
@Override
public String toString() {
StringBuilder sb = S.builder(type());
if (S.notBlank(name)) {
sb.append("(").append(name).append(")");
}
C.List<Object> list = C.newList();
if (null != valueLoader) {
list.append(valueLoader);
} else {
list.append(qualifiers).append(elementLoaders).append(filters);
if (null != mapKey) {
list.append(mapKey);
}
}
if (null != scope) {
list.append(scope.getSimpleName());
}
if (!list.isEmpty()) {
sb.append("@[").append(S.join(", ", list)).append("]");
}
return sb.toString();
}
示例5: load
import org.osgl.util.C; //导入依赖的package包/类
@Override
public List<Integer> load(Map<String, Object> options, BeanSpec container, Genie genie) {
int max = toInt(options.get("max"));
int n1 = 1, n2 = 1, f;
List<Integer> list = C.newList();
list.add(n1);
list.add(n2);
for (;;) {
f = n1 + n2;
n1 = n2;
n2 = f;
if (f < max) {
list.add(f);
} else {
break;
}
}
return list;
}
示例6: annotatedElementLoaderProvider
import org.osgl.util.C; //导入依赖的package包/类
@Provides
public static AnnotatedElementLoader annotatedElementLoaderProvider() {
return new AnnotatedElementLoader() {
@Override
protected List<Class<?>> load(
Class<? extends Annotation> annoClass,
boolean loadNonPublic,
boolean loadAbstract
) {
if (annoClass == BindingType.class) {
if (loadNonPublic && loadAbstract) {
return C.list(PublicAnnotated.class, PrivateAnnotated.class, AbstractAnnotated.class);
}
if (loadNonPublic) {
return C.list(PublicAnnotated.class, PrivateAnnotated.class);
}
if (loadAbstract) {
return C.list(PublicAnnotated.class, AbstractAnnotated.class);
}
return C.<Class<?>>list(PublicAnnotated.class);
}
throw E.unsupport();
}
};
}
示例7: typedElementLoader
import org.osgl.util.C; //导入依赖的package包/类
@Provides
public static TypedElementLoader typedElementLoader() {
return new TypedElementLoader() {
@Override
protected List<Class> load(Class type, boolean loadNonPublic, boolean loadAbstract, boolean loadRoot) {
if (type == Base.class) {
List<Class> list = (List) C.newList(Derived.class);
if (loadNonPublic) {
list.add(NonPublicDerived.class);
}
if (loadAbstract) {
list.add(AbstractDerived.class);
}
if (loadRoot) {
list.add(Base.class);
}
return list;
}
return C.list();
}
};
}
示例8: save
import org.osgl.util.C; //导入依赖的package包/类
@Override
public List<MODEL_TYPE> save(Iterable<MODEL_TYPE> iterable) {
List<MODEL_TYPE> list = C.list(iterable);
if (list.isEmpty()) {
return list;
}
Transaction transaction = ebean().createTransaction(TxIsolation.READ_COMMITED);
transaction.setBatchMode(true);
transaction.setBatchSize(list.size());
try {
ebean().saveAll(list);
transaction.commit();
} catch (RuntimeException e) {
transaction.rollback();
throw e;
} finally {
transaction.end();
}
return list;
}
示例9: fetch
import org.osgl.util.C; //导入依赖的package包/类
@Override
public Iterable<MODEL_TYPE> fetch() {
C.List<MODEL_TYPE> list = C.newList();
QueryIterator<MODEL_TYPE> qi = findIterate();
while (qi.hasNext()) {
list.add(qi.next());
}
qi.close();
return list;
// we need to close the query iterable right now otherwise it hold the data connection forever
// return new Iterable<MODEL_TYPE>() {
// @Override
// public Iterator<MODEL_TYPE> iterator() {
// return findIterate();
// }
// };
}
示例10: permissions
import org.osgl.util.C; //导入依赖的package包/类
/**
*
* @return
*/
@Override
public List<? extends Permission> permissions() {
List<String> names = permissionNames();
if (names.isEmpty()) {
return C.list();
}
AAAContext aaa = AAA.context();
AAAPersistentService ps = aaa.getPersistentService();
List<Permission> perms = C.newList();
for (String name: names) {
Permission p = ps.findByName(name, Permission.class);
perms.add($.notNull(p));
}
return perms;
}
示例11: loadWords
import org.osgl.util.C; //导入依赖的package包/类
private static List<String> loadWords() {
URL url = Zen.class.getResource("/act_zen.txt");
List<String> words = C.newList(defaultWords());
if (null != url) {
try {
List<String> myWords = IO.readLines(url.openStream());
if (!myWords.isEmpty()) {
words = myWords;
}
} catch (Exception e) {
// ignore it
}
}
List<String> retVal = new ArrayList<>(words.size());
for (String s : words) {
if (s.contains("\n")) {
s = s.replaceAll("\n", "\n ");
} else if (s.contains("\\n")) {
s = s.replaceAll("\\\\n", "\n ");
}
retVal.add(s);
}
return retVal;
}
示例12: loadConfFromDir_
import org.osgl.util.C; //导入依赖的package包/类
private Map loadConfFromDir_(File confDir) {
File[] confFiles = confDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".properties") || name.endsWith(".conf");
}
});
if (null == confFiles) {
return C.Map();
} else {
Map map = new HashMap<>();
int n = confFiles.length;
for (int i = 0; i < n; ++i) {
map.putAll(loadConfFromFile(confFiles[i]));
}
return map;
}
}
示例13: setup
import org.osgl.util.C; //导入依赖的package包/类
@Before
public void setup() throws Exception {
super.setup();
scanner = new CommanderByteCodeScanner();
scannerManager = mock(AppCodeScannerManager.class);
jobManager = mock(JobManager.class);
classLoader = new TestingAppClassLoader(mockApp);
dispatcher = new CliDispatcher(mockApp);
when(mockApp.classLoader()).thenReturn(classLoader);
infoSrc = classLoader.commanderClassMetaInfoManager();
when(mockApp.classLoader()).thenReturn(classLoader);
when(mockApp.cliDispatcher()).thenReturn(dispatcher);
when(mockApp.scannerManager()).thenReturn(scannerManager);
when(mockApp.jobManager()).thenReturn(jobManager);
when(mockAppConfig.possibleControllerClass(anyString())).thenReturn(true);
when(mockRouter.isActionMethod(anyString(), anyString())).thenReturn(false);
C.List<AppByteCodeScanner> scanners = $.cast(C.listOf(scanner));
when(scannerManager.byteCodeScanners()).thenReturn(scanners);
scanner.setApp(mockApp);
base = new File("./target/test-classes");
}
示例14: defaultWords
import org.osgl.util.C; //导入依赖的package包/类
private static List<String> defaultWords() {
return C.listOf(
"Beautiful is better than ugly.",
"Explicit is better than implicit.",
"Simple is better than complex.",
"Complex is better than complicated.",
"Flat is better than nested.",
"Sparse is better than dense.",
"Readability counts.",
"Special cases aren't special enough to break the rules. \n" +
"Although practicality beats purity.",
"Errors should never pass silently \n" +
"Unless explicitly silenced.",
"In the face of ambiguity, refuse the temptation to guess.",
"There should be one-- and preferably only one --obvious way to do it.\n" +
"Although that way may not be obvious at first unless you're Dutch.",
"Now is better than never. \n" +
"Although never is often better than *right* now.",
"If the implementation is hard to explain, it's a bad idea.",
"If the implementation is easy to explain, it may be a good idea.",
"Namespaces are one honking great idea -- let's do more of those!",
"Simple things should be simple, complex things should be possible."
);
}
示例15: staticWithoutReturnValue
import org.osgl.util.C; //导入依赖的package包/类
@Test
public void staticWithoutReturnValue() {
scan(StaticWithoutReturnType.class);
CommanderClassMetaInfo classMetaInfo = infoSrc.commanderMetaInfo(StaticWithoutReturnType.class.getName());
CommandMethodMetaInfo methodMetaInfo = classMetaInfo.command("foo.bar");
eq("doIt", methodMetaInfo.methodName());
eq(StaticWithoutReturnType.class.getName() + ".doIt", methodMetaInfo.fullName());
eq("help", methodMetaInfo.helpMsg());
yes(methodMetaInfo.isStatic());
assertNull(methodMetaInfo.propertySpec());
eq(AsmTypes.RETURN_VOID, methodMetaInfo.returnType());
C.List<CommandParamMetaInfo> params = methodMetaInfo.params();
eq(2, params.size());
CommandParamMetaInfo op = params.get(0);
eq("op1", op.name());
ParamOptionAnnoInfo anno = op.optionInfo();
eq("-o", anno.lead1());
eq("--op1", anno.lead2());
op = params.get(1);
eq("num", op.name());
anno = op.optionInfo();
eq("-n", anno.lead1());
eq("--number", anno.lead2());
}