本文整理了Java中clojure.lang.Keyword.intern()
方法的一些代码示例,展示了Keyword.intern()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keyword.intern()
方法的具体详情如下:
包路径:clojure.lang.Keyword
类名称:Keyword
方法名:intern
暂无
代码示例来源:origin: alibaba/jstorm
private Keyword makeKeyword(String name) {
return Keyword.intern(Symbol.create(name));
}
代码示例来源:origin: alibaba/jstorm
public StormTopology getTopology() {
return (StormTopology) get(Keyword.intern("topology"));
}
}
代码示例来源:origin: alibaba/mdrill
private final Keyword makeKeyword(String name) {
return Keyword.intern(Symbol.create(name));
}
代码示例来源:origin: org.clojure/tools.nrepl
public String newSession (String cloneSessionId) {
try {
if (cloneSessionId == null) {
return (String)newSession.invoke(client);
} else {
return (String)newSession.invoke(client, Keyword.intern("clone"), cloneSessionId);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.clojure/tools.nrepl
public Response sendSession (String session, String... kvs) {
try {
Map msg = PersistentHashMap.createWithCheck(kvs);
return new Response((ISeq)message.invoke(
clientSession.invoke(client, Keyword.intern("session"), session), msg));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: alibaba/jstorm
@SuppressWarnings("unchecked")
@Override
public void open(final Map conf, final TopologyContext context, final SpoutOutputCollector collector) {
IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
try {
IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
final Map<Keyword, Object> collectorMap =
new PersistentArrayMap(new Object[]{Keyword.intern(Symbol.create("output-collector")), collector,
Keyword.intern(Symbol.create("context")), context});
List<Object> args = new ArrayList<Object>() {
{
add(conf);
add(context);
add(collectorMap);
}
};
_spout = (ISpout) preparer.applyTo(RT.seq(args));
// this is kind of unnecessary for clojure
try {
_spout.open(conf, context, collector);
} catch (AbstractMethodError ignored) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: alibaba/jstorm
@SuppressWarnings("unchecked")
@Override
public void prepare(final Map stormConf, final TopologyContext context, final OutputCollector collector) {
IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
try {
IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
final Map<Keyword, Object> collectorMap =
new PersistentArrayMap(new Object[]{Keyword.intern(Symbol.create("output-collector")), collector,
Keyword.intern(Symbol.create("context")), context});
List<Object> args = new ArrayList<Object>() {
{
add(stormConf);
add(context);
add(collectorMap);
}
};
_bolt = (IBolt) preparer.applyTo(RT.seq(args));
// this is kind of unnecessary for clojure
try {
_bolt.prepare(stormConf, context, collector);
} catch (AbstractMethodError ignored) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: alibaba/mdrill
@Override
public void prepare(final Map stormConf, final TopologyContext context, final OutputCollector collector) {
IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
try {
IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
final Map<Keyword,Object> collectorMap = new PersistentArrayMap( new Object[] {
Keyword.intern(Symbol.create("output-collector")), collector,
Keyword.intern(Symbol.create("context")), context});
List<Object> args = new ArrayList<Object>() {{
add(stormConf);
add(context);
add(collectorMap);
}};
_bolt = (IBolt) preparer.applyTo(RT.seq(args));
//this is kind of unnecessary for clojure
try {
_bolt.prepare(stormConf, context, collector);
} catch(AbstractMethodError ame) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: alibaba/mdrill
@Override
public void open(final Map conf, final TopologyContext context, final SpoutOutputCollector collector) {
IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
try {
IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
final Map<Keyword,Object> collectorMap = new PersistentArrayMap( new Object[] {
Keyword.intern(Symbol.create("output-collector")), collector,
Keyword.intern(Symbol.create("context")), context});
List<Object> args = new ArrayList<Object>() {{
add(conf);
add(context);
add(collectorMap);
}};
_spout = (ISpout) preparer.applyTo(RT.seq(args));
//this is kind of unnecessary for clojure
try {
_spout.open(conf, context, collector);
} catch(AbstractMethodError ame) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: palantir/atlasdb
private static Map<Keyword, Object> createClojureMapFromResults(CheckerResult results) {
List<Map<Keyword, Object>> errorsAsClojureHistory = convertEventListToClojureHistory(results.errors());
return ImmutableMap.of(
Keyword.intern("valid?"), results.valid(),
Keyword.intern("errors"), errorsAsClojureHistory);
}
代码示例来源:origin: palantir/atlasdb
@Test
public void canDeserialiseInfoReadWithValue() {
Map<Keyword, Object> keywordMap = new HashMap<>();
keywordMap.put(Keyword.intern("type"), Keyword.intern("info"));
keywordMap.put(Keyword.intern("f"), Keyword.intern(JepsenConstants.START_FUNCTION));
keywordMap.put(Keyword.intern("process"), Keyword.intern(JepsenConstants.NEMESIS_PROCESS_NAME));
keywordMap.put(Keyword.intern("time"), SOME_TIME);
keywordMap.put(Keyword.intern("value"), Keyword.intern(SOME_LONG_AS_STRING));
Event event = Event.fromKeywordMap(keywordMap);
assertThat(event).isInstanceOf(InfoEvent.class);
}
代码示例来源:origin: palantir/atlasdb
@Test
public void canDeserialiseInfoReadWithoutValue() {
Map<Keyword, Object> keywordMap = new HashMap<>();
keywordMap.put(Keyword.intern("type"), Keyword.intern("info"));
keywordMap.put(Keyword.intern("f"), Keyword.intern(JepsenConstants.START_FUNCTION));
keywordMap.put(Keyword.intern("process"), Keyword.intern(JepsenConstants.NEMESIS_PROCESS_NAME));
keywordMap.put(Keyword.intern("time"), SOME_TIME);
Event event = Event.fromKeywordMap(keywordMap);
assertThat(event).isInstanceOf(InfoEvent.class);
}
代码示例来源:origin: palantir/atlasdb
@Test
public void makeSureWeCanHaveNullValues() {
Map<Keyword, Object> keywordMap = new HashMap<>();
keywordMap.put(Keyword.intern("type"), Keyword.intern("info"));
keywordMap.put(Keyword.intern("f"), Keyword.intern(JepsenConstants.START_FUNCTION));
keywordMap.put(Keyword.intern("process"), Keyword.intern(JepsenConstants.NEMESIS_PROCESS_NAME));
keywordMap.put(Keyword.intern("time"), SOME_TIME);
keywordMap.put(Keyword.intern("value"), null);
Event event = Event.fromKeywordMap(keywordMap);
assertThat(event).isInstanceOf(InfoEvent.class);
assertThat(((InfoEvent) event).value().isPresent()).isFalse();
}
代码示例来源:origin: palantir/atlasdb
@Test
public void incorrectHistoryShouldReturnInvalidWithErrors() {
Checker checker = createMockedChecker(false, INFO_EVENT);
Map<Keyword, Object> results = runJepsenChecker(checker);
Map<Keyword, Object> expectedResults = ImmutableMap.of(Keyword.intern("valid?"), false,
Keyword.intern("errors"), ImmutableList.of(INFO_EVENT));
assertThat(results).isEqualTo(expectedResults);
}
代码示例来源:origin: palantir/atlasdb
@Test
public void correctHistoryShouldReturnValidAndNoErrors() {
Checker checker = createMockedChecker(true);
Map<Keyword, Object> results = runJepsenChecker(checker);
Map<Keyword, Object> expectedResults = ImmutableMap.of(Keyword.intern("valid?"), true,
Keyword.intern("errors"), ImmutableList.of());
assertThat(results).isEqualTo(expectedResults);
}
代码示例来源:origin: palantir/atlasdb
@Test
public void invalidIfOneOutOfTwoCheckersFails() {
Checker firstChecker = createMockedChecker(false, INFO_EVENT);
Checker secondChecker = createMockedChecker(true);
Map<Keyword, Object> results = runJepsenChecker(firstChecker, secondChecker);
Map<Keyword, Object> expectedResults = ImmutableMap.of(Keyword.intern("valid?"), false,
Keyword.intern("errors"), ImmutableList.of(INFO_EVENT));
assertThat(results).isEqualTo(expectedResults);
}
代码示例来源:origin: palantir/atlasdb
@Test
public void ifTwoCheckersFailErrorsAreCombined() {
Checker firstChecker = createMockedChecker(false, INFO_EVENT);
Checker secondChecker = createMockedChecker(false, INVOKE_EVENT);
Map<Keyword, Object> results = runJepsenChecker(firstChecker, secondChecker);
Map<Keyword, Object> expectedResults = ImmutableMap.of(Keyword.intern("valid?"), false,
Keyword.intern("errors"), ImmutableList.of(INFO_EVENT, INVOKE_EVENT));
assertThat(results).isEqualTo(expectedResults);
}
代码示例来源:origin: palantir/atlasdb
@Test
public void canSerialiseInfoEventWithoutValue() {
Event infoEvent = ImmutableInfoEvent.builder()
.function("foo")
.process(SOME_PROCESS)
.time(SOME_TIME)
.build();
Map<Keyword, Object> expected = ImmutableMap.of(
Keyword.intern("type"), "info",
Keyword.intern("f"), "foo",
Keyword.intern("process"), SOME_PROCESS,
Keyword.intern("time"), SOME_TIME);
assertThat(Event.toKeywordMap(infoEvent)).isEqualTo(expected);
}
}
代码示例来源:origin: palantir/atlasdb
@Test
public void correctLockTestHistoryShouldReturnValidAndNoErrors() throws IOException {
List<Map<Keyword, ?>> convertedAllEvents = getClojureMapFromFile("lock_test_without_nemesis.json");
Map<Keyword, Object> results = JepsenHistoryCheckers.createWithLockCheckers()
.checkClojureHistory(convertedAllEvents);
assertThat(results).containsEntry(Keyword.intern("valid?"), true);
assertThat(results).containsEntry(Keyword.intern("errors"), ImmutableList.of());
}
代码示例来源:origin: palantir/atlasdb
@Test
public void correctExampleHistoryShouldReturnValidAndNoErrors() throws IOException {
List<Map<Keyword, ?>> convertedAllEvents = getClojureMapFromFile("correct_history.json");
Map<Keyword, Object> results = JepsenHistoryCheckers.createWithTimestampCheckers()
.checkClojureHistory(convertedAllEvents);
assertThat(results).containsEntry(Keyword.intern("valid?"), true);
assertThat(results).containsEntry(Keyword.intern("errors"), ImmutableList.of());
}
内容来源于网络,如有侵权,请联系作者删除!