private List<ParameterValueMapping> _generateArguments(final TAbstractMessages tMessage, final Operation operation, final Lifeline lifeline) { List<ParameterValueMapping> _xblockexpression = null; { final List<ParameterValueMapping> result = CollectionLiterals.<ParameterValueMapping>newArrayList(); EList<Parameter> _parameters = operation.getParameters(); boolean _isEmpty = _parameters.isEmpty(); boolean _equals = (_isEmpty == false); if (_equals) { EList<Parameter> _parameters_1 = operation.getParameters(); int _length = ((Object[])Conversions.unwrapArray(_parameters_1, Object.class)).length; int _minus = (_length - 1); IntegerRange _upTo = new IntegerRange(0, _minus); for (final Integer i : _upTo) { EList<Parameter> _parameters_2 = operation.getParameters(); Parameter _get = _parameters_2.get((i).intValue()); EList<TParameter> _arguments = tMessage.getArguments(); TParameter _get_1 = _arguments.get((i).intValue()); ParameterValueMapping _createParameterValueMapping = this.createParameterValueMapping(_get, _get_1, lifeline); result.add(_createParameterValueMapping); } } _xblockexpression = result; } return _xblockexpression; }
public void generateParameters(final JvmExecutable it, final ITreeAppendable appendable, final GeneratorConfig config) { boolean _isEmpty = it.getParameters().isEmpty(); boolean _not = (!_isEmpty); if (_not) { int _size = it.getParameters().size(); int _minus = (_size - 1); IntegerRange _upTo = new IntegerRange(0, _minus); for (final Integer i : _upTo) { { int _size_1 = it.getParameters().size(); final boolean last = (((i).intValue() + 1) == _size_1); final JvmFormalParameter p = it.getParameters().get((i).intValue()); this.generateParameter(p, appendable, (last && it.isVarArgs()), config); if ((!last)) { appendable.append(", "); } } } } }
public String getIndentation(final int levels) { String _xifexpression = null; if ((levels > 0)) { String _xblockexpression = null; { final String indent = this.cfg.get(BasicFormatterPreferenceKeys.indentation); final Function1<Integer, String> _function = (Integer it) -> { return indent; }; _xblockexpression = IterableExtensions.join(IterableExtensions.<Integer, String>map(new IntegerRange(0, (levels - 1)), _function)); } _xifexpression = _xblockexpression; } else { _xifexpression = ""; } return _xifexpression; }
public String getWrap(final int levels) { String _xifexpression = null; if ((levels > 0)) { String _xblockexpression = null; { final String sep = this.cfg.get(BasicFormatterPreferenceKeys.lineSeparator); final Function1<Integer, String> _function = (Integer it) -> { return sep; }; _xblockexpression = IterableExtensions.join(IterableExtensions.<Integer, String>map(new IntegerRange(0, (levels - 1)), _function)); } _xifexpression = _xblockexpression; } else { _xifexpression = ""; } return _xifexpression; }
@Test public void testValidity() { new IntegerRange(0, 0, 1); new IntegerRange(0, 0, -1); new IntegerRange(0, 2, 1); new IntegerRange(-1, 2, 1); new IntegerRange(-2, -1, 1); new IntegerRange(2, 0, -1); new IntegerRange(2, -1, -1); new IntegerRange(-1, -2, -1); new IntegerRange(-2, 0, 1); new IntegerRange(Integer.MIN_VALUE, 0, 1); new IntegerRange(Integer.MAX_VALUE, 0, -1); assertInvalid(0, 1, 0); assertInvalid(0, 2, -1); assertInvalid(-1, 2, -1); assertInvalid(-2, -1, -1); assertInvalid(2, 0, 1); assertInvalid(2, -1, 1); assertInvalid(-1, -2, 1); }
@Test public void testLongInputManyTasks() { final int expectation = 100000; StringConcatenation _builder = new StringConcatenation(); _builder.append("/*"); _builder.newLine(); { IntegerRange _upTo = new IntegerRange(1, expectation); for(final Integer i : _upTo) { _builder.append(" "); _builder.append("* FIXME this cannot work"); _builder.newLine(); } } _builder.append(" "); _builder.append("*/"); _builder.newLine(); final String source = _builder.toString(); final List<Task> parsed = this.parser.parseTasks(LineDelimiters.toUnix(source), this.definitions); Assert.assertEquals(expectation, parsed.size()); ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, expectation, true); for (final Integer i_1 : _doubleDotLessThan) { Assert.assertEquals(((i_1).intValue() + 2), parsed.get((i_1).intValue()).getLineNumber()); } }
@Test public void test_rates() { try { final PropertyNode m = Metrics.create(); IntegerRange _upTo = new IntegerRange(1, 8); for (final Integer i : _upTo) { IntegerRange _upTo_1 = new IntegerRange(1, 10); for (final Integer j : _upTo_1) { { m.<Long>record(Metrics.happened("de.mxro.test.meter1")); Thread.sleep(100); } } } double _fiveMinuteRate = m.<Meter>retrieve("de.mxro.test.meter1", Meter.class).get().getFiveMinuteRate(); boolean _greaterThan = (_fiveMinuteRate > 8.0); TestMeter.<Boolean, Boolean>operator_doubleArrow(Boolean.valueOf(_greaterThan), Boolean.valueOf(true)); double _fiveMinuteRate_1 = m.<Meter>retrieve("de.mxro.test.meter1", Meter.class).get().getFiveMinuteRate(); boolean _lessThan = (_fiveMinuteRate_1 < 12.0); TestMeter.<Boolean, Boolean>operator_doubleArrow(Boolean.valueOf(_lessThan), Boolean.valueOf(true)); m.stop().get(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private List<ParameterValueMapping> _generateArguments(final TMessage tMessage, final Operation operation, final Lifeline lifeline) { List<ParameterValueMapping> _xblockexpression = null; { final List<ParameterValueMapping> result = CollectionLiterals.<ParameterValueMapping>newArrayList(); EList<Parameter> _parameters = operation.getParameters(); boolean _isEmpty = _parameters.isEmpty(); boolean _equals = (_isEmpty == false); if (_equals) { EList<Parameter> _parameters_1 = operation.getParameters(); int _length = ((Object[])Conversions.unwrapArray(_parameters_1, Object.class)).length; int _minus = (_length - 1); IntegerRange _upTo = new IntegerRange(0, _minus); for (final Integer i : _upTo) { EList<Parameter> _parameters_2 = operation.getParameters(); Parameter _get = _parameters_2.get((i).intValue()); EList<TValueSpecification> _arguments = tMessage.getArguments(); TValueSpecification _get_1 = _arguments.get((i).intValue()); ParameterValueMapping _createParameterValueMapping = this.createParameterValueMapping(_get, _get_1, lifeline); result.add(_createParameterValueMapping); } } _xblockexpression = result; } return _xblockexpression; }
protected boolean isWhitespace(final String doc) { int _length = doc.length(); int _minus = (_length - 1); final Function1<Integer, Boolean> _function = (Integer it) -> { return Boolean.valueOf(Character.isWhitespace(doc.charAt((it).intValue()))); }; return IterableExtensions.<Integer>forall(new IntegerRange(0, _minus), _function); }
@IgnoredBySmokeTest("Do not run smoke test with 1000s of nested expressions") @Test public void testBlockExpression_03() throws Exception { String input = "{ val s1 = \'\'\n"; final int max = 1000; IntegerRange _upTo = new IntegerRange(1, max); for (final Integer i : _upTo) { input = (((((input + " val s") + Integer.valueOf(((i).intValue() + 1))) + " = s") + i) + "\n"); } input = (((input + " s") + Integer.valueOf((max + 1))) + "}"); this.resolvesTo(input, "String"); }
protected void assertInvalid(int start, int end, int step) { try { new IntegerRange(start, end, step); fail("Invalid step not detected"); } catch (IllegalArgumentException e) { // expected exception } }
@Test public void testContains_0() { IntegerRange range = new IntegerRange(-1, 1, 2); assertFalse(range.contains(-2)); assertTrue(range.contains(-1)); assertFalse(range.contains(0)); assertTrue(range.contains(1)); assertFalse(range.contains(2)); }
@Test public void testContains_1() { IntegerRange range = new IntegerRange(-1, 2, 2); assertFalse(range.contains(-2)); assertTrue(range.contains(-1)); assertFalse(range.contains(0)); assertTrue(range.contains(1)); assertFalse(range.contains(2)); }
@Test public void testSize() { final IntegerRange myRange = new IntegerRange(-1, 1); assertEquals(3, myRange.getSize()); assertEquals(2, myRange.withStep(2).getSize()); assertEquals(1, myRange.withStep(3).getSize()); final IntegerRange myRange2 = new IntegerRange(1, -1); assertEquals(3, myRange2.getSize()); assertEquals(2, myRange2.withStep(-2).getSize()); assertEquals(1, myRange2.withStep(-3).getSize()); }
@Test public void testWeirdTemplateString() { StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("fooo bar"); _builder.newLine(); _builder.append("d "); { if ((2 > 1)) { _builder.append("s"); _builder.newLineIfNotEmpty(); _builder.append("\t "); _builder.append("ee "); { IntegerRange _upTo = new IntegerRange(1, 4); for(final Integer i : _upTo) { _builder.newLineIfNotEmpty(); _builder.newLineIfNotEmpty(); CharSequence _other = TemplateNodeTest.this.other(); _builder.append(_other); _builder.append(" "); _builder.append(i); _builder.newLineIfNotEmpty(); String _multiLineString = TemplateNodeTest.this.multiLineString(); _builder.append(_multiLineString); _builder.append(" "); String _multiLineString_1 = TemplateNodeTest.this.multiLineString(); _builder.append(_multiLineString_1); _builder.newLineIfNotEmpty(); } } } } } }; this.assertEquals(_client); }
public static CharSequence phone() { StringConcatenation _builder = new StringConcatenation(); _builder.append("1"); _builder.append(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("1", "3", "5", "8")), ""); _builder.append(".get(RandomUtils.nextInt(0, 3))»"); IntegerRange _upTo = new IntegerRange(0, 8); final Function1<Integer, String> _function = (Integer it) -> { Integer _singleNumber = Randoms.singleNumber(); return _singleNumber.toString(); }; Iterable<String> _map = IterableExtensions.<Integer, String>map(_upTo, _function); String _join = IterableExtensions.join(_map); _builder.append(_join, ""); return _builder; }
public static void main(final String[] args) { final Runnable _function = () -> { InputOutput.<String>println("Hello I’m executed!"); }; final Runnable runnable = _function; final Callable<String> _function_1 = () -> { return InputOutput.<String>println("Hello I’m executed!"); }; final Callable<String> callable = _function_1; final FutureTask<String> task = new FutureTask<String>(callable); final Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); Thread _thread = new Thread(runnable); _thread.start(); IntegerRange _upTo = new IntegerRange(1, 1000000); final Consumer<Integer> _function_2 = (Integer index) -> { Thread _thread_1 = new Thread(task); _thread_1.start(); }; _upTo.forEach(_function_2); stopwatch.stop(); StringConcatenation _builder = new StringConcatenation(); _builder.append("ThreadSystem Hello-Tung Cost "); long _elapsed = stopwatch.elapsed(TimeUnit.MILLISECONDS); _builder.append(_elapsed, ""); _builder.append(" ms ( is "); long _elapsed_1 = stopwatch.elapsed(TimeUnit.NANOSECONDS); _builder.append(_elapsed_1, ""); _builder.append(" ns )"); InputOutput.<String>println(_builder.toString()); }
public static void main(final String[] args) { final Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); final ActorSystem system = ActorSystem.create("Hello-Tung"); Props _create = Props.create(GreetingActor.class); final ActorRef greeter = system.actorOf(_create, "greeter"); Greeting _greeting = new Greeting("Tung Out Room"); ActorRef _noSender = ActorRef.noSender(); greeter.tell(_greeting, _noSender); IntegerRange _upTo = new IntegerRange(1, 10); final Consumer<Integer> _function = (Integer index) -> { Props _create_1 = Props.create(GreetingActor.class); final ActorRef in = system.actorOf(_create_1, ("greeter" + index)); Greeting _greeting_1 = new Greeting(("Tung In Room" + index)); ActorRef _noSender_1 = ActorRef.noSender(); in.tell(_greeting_1, _noSender_1); }; _upTo.forEach(_function); stopwatch.stop(); StringConcatenation _builder = new StringConcatenation(); _builder.append("ActorSystem Hello-Tung Cost "); long _elapsed = stopwatch.elapsed(TimeUnit.MILLISECONDS); _builder.append(_elapsed, ""); _builder.append(" ms ( is "); long _elapsed_1 = stopwatch.elapsed(TimeUnit.NANOSECONDS); _builder.append(_elapsed_1, ""); _builder.append(" ns )"); InputOutput.<String>println(_builder.toString()); }
public static void draw(final Renderer renderer, final ComplexBarShape shape) { final List<Float> sizes = shape.getSizes(); final FloatPoint startCoordinate = shape.getStartCoordinate(); final FloatPoint endCoordinate = shape.getEndCoordinate(); Iterable<Float> _startCoordinates = DrawComplexBarShape.getStartCoordinates(sizes); final Iterator<Float> startCoordinates = _startCoordinates.iterator(); Iterable<Float> _endCoordinates = DrawComplexBarShape.getEndCoordinates(sizes); final Iterator<Float> endCoordinates = _endCoordinates.iterator(); Iterable<Color> _colors = shape.getColors(); final Iterator<Color> colors = _colors.iterator(); final float distance = (endCoordinate.x - startCoordinate.x); int _size = sizes.size(); int _minus = (_size - 1); IntegerRange _upTo = new IntegerRange(0, _minus); for (final int i : _upTo) { { Color _next = colors.next(); final com.badlogic.gdx.graphics.Color color = ColorConvert.convert(_next); Float _next_1 = startCoordinates.next(); float _multiply = (distance * (_next_1).floatValue()); final float spos = (startCoordinate.x + _multiply); Float _next_2 = endCoordinates.next(); float _multiply_1 = (distance * (_next_2).floatValue()); final float epos = (startCoordinate.x + _multiply_1); final FloatPoint start = new FloatPoint(spos, startCoordinate.y); final FloatPoint end = new FloatPoint(epos, endCoordinate.y); renderer.drawBox(start, end, color); } } }
@Test public void test_rates() { try { final PropertyNode m = Metrics.create(); IntegerRange _upTo = new IntegerRange(1, 8); for (final Integer i : _upTo) { IntegerRange _upTo_1 = new IntegerRange(1, 10); for (final Integer j : _upTo_1) { { PropertyOperation<Long> _happened = Metrics.happened("de.mxro.test.meter1"); m.<Long>record(_happened); Thread.sleep(100); } } } Promise<Meter> _retrieve = m.<Meter>retrieve("de.mxro.test.meter1", Meter.class); Meter _get = _retrieve.get(); double _fiveMinuteRate = _get.getFiveMinuteRate(); boolean _greaterThan = (_fiveMinuteRate > 8.0); TestMeter.<Boolean, Boolean>operator_doubleArrow(Boolean.valueOf(_greaterThan), Boolean.valueOf(true)); Promise<Meter> _retrieve_1 = m.<Meter>retrieve("de.mxro.test.meter1", Meter.class); Meter _get_1 = _retrieve_1.get(); double _fiveMinuteRate_1 = _get_1.getFiveMinuteRate(); boolean _lessThan = (_fiveMinuteRate_1 < 12.0); TestMeter.<Boolean, Boolean>operator_doubleArrow(Boolean.valueOf(_lessThan), Boolean.valueOf(true)); Promise<Success> _stop = m.stop(); _stop.get(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private boolean haveSameArgumentsTypeOnMessageInteraction(final EList<TParameter> list, final EList<TValueSpecification> list2) { try { int _size = list.size(); int _size_1 = list2.size(); boolean _notEquals = (_size != _size_1); if (_notEquals) { throw new Exception("Argument\'s lists are not the same size"); } boolean _and = false; boolean _isEmpty = list.isEmpty(); boolean _equals = (_isEmpty == false); if (!_equals) { _and = false; } else { boolean _isEmpty_1 = list2.isEmpty(); boolean _equals_1 = (_isEmpty_1 == false); _and = _equals_1; } if (_and) { int _size_2 = list.size(); int _minus = (_size_2 - 1); IntegerRange _upTo = new IntegerRange(0, _minus); for (final Integer i : _upTo) { TParameter _get = list.get((i).intValue()); Type _type = _get.getType(); String _name = _type.getName(); TValueSpecification _get_1 = list2.get((i).intValue()); String _typeNameForTValueSpecification = this.getTypeNameForTValueSpecification(_get_1); boolean _notEquals_1 = (!Objects.equal(_name, _typeNameForTValueSpecification)); if (_notEquals_1) { return false; } } } return true; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private boolean haveSameArgumentsType(final EList<TParameter> list, final EList<TParameter> list2) { try { int _size = list.size(); int _size_1 = list2.size(); boolean _notEquals = (_size != _size_1); if (_notEquals) { throw new Exception("Argument\'s lists are not the same size"); } boolean _and = false; boolean _isEmpty = list.isEmpty(); boolean _equals = (_isEmpty == false); if (!_equals) { _and = false; } else { boolean _isEmpty_1 = list2.isEmpty(); boolean _equals_1 = (_isEmpty_1 == false); _and = _equals_1; } if (_and) { int _size_2 = list.size(); int _minus = (_size_2 - 1); IntegerRange _upTo = new IntegerRange(0, _minus); for (final Integer i : _upTo) { TParameter _get = list.get((i).intValue()); Type _type = _get.getType(); String _name = _type.getName(); TParameter _get_1 = list2.get((i).intValue()); Type _type_1 = _get_1.getType(); String _name_1 = _type_1.getName(); boolean _notEquals_1 = (!Objects.equal(_name, _name_1)); if (_notEquals_1) { return false; } } } return true; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private static boolean operationThatMatchSignature(final TOperation current, final Operation toCompare) { String _name = current.getName(); String _name_1 = toCompare.getName(); boolean _notEquals = (!Objects.equal(_name, _name_1)); if (_notEquals) { return false; } EList<TParameter> _parameters = current.getParameters(); int _size = _parameters.size(); EList<Parameter> _parameters_1 = toCompare.getParameters(); int _size_1 = _parameters_1.size(); boolean _notEquals_1 = (_size != _size_1); if (_notEquals_1) { return false; } EList<TParameter> _parameters_2 = current.getParameters(); int _size_2 = _parameters_2.size(); boolean _greaterThan = (_size_2 > 0); if (_greaterThan) { EList<Parameter> _parameters_3 = toCompare.getParameters(); int _size_3 = _parameters_3.size(); int _minus = (_size_3 - 1); IntegerRange _upTo = new IntegerRange(0, _minus); for (final Integer i : _upTo) { EList<Parameter> _parameters_4 = toCompare.getParameters(); Parameter _get = _parameters_4.get((i).intValue()); Type _type = _get.getType(); String _name_2 = _type.getName(); EList<TParameter> _parameters_5 = current.getParameters(); TParameter _get_1 = _parameters_5.get((i).intValue()); Type _type_1 = _get_1.getType(); String _name_3 = _type_1.getName(); boolean _notEquals_2 = (!Objects.equal(_name_2, _name_3)); if (_notEquals_2) { return false; } } } return true; }
@Test public void testDefaultStep() { assertEquals(1, new IntegerRange(0, 10).getStep()); assertEquals(-1, new IntegerRange(10, 0).getStep()); assertEquals(1, new IntegerRange(10, 10).getStep()); }
public static Integer singleNumber() { IntegerRange _upTo = new IntegerRange(0, 9); List<Integer> _list = IterableExtensions.<Integer>toList(_upTo); int _nextInt = RandomUtils.nextInt(0, 9); return _list.get(_nextInt); }
/** * example: toNotebook(Car) * Car.attribute will contain: Name (per default), color, length, width, height, weight * attribute.access will be WRITE (all attributes are visible and values can be changed) */ public String toNotebook(final Relation r) { String notebook = ""; EList<Attribute> _attribute = r.getAttribute(); boolean _isEmpty = _attribute.isEmpty(); if (_isEmpty) { return notebook; } EList<Attribute> _attribute_1 = r.getAttribute(); int _size = _attribute_1.size(); int _minus = (_size - 1); IntegerRange _upTo = new IntegerRange(0, _minus); for (final Integer i : _upTo) { { EList<Attribute> _attribute_2 = r.getAttribute(); Attribute attr = _attribute_2.get((i).intValue()); AccessType _access = attr.getAccess(); boolean _equals = Objects.equal(_access, AccessType.WRITE); if (_equals) { String _plus = (notebook + "ATTR "); String _plus_1 = (_plus + "\\\""); String _name = attr.getName(); String _plus_2 = (_plus_1 + _name); String _plus_3 = (_plus_2 + "\\\""); String _plus_4 = (_plus_3 + "\n"); notebook = _plus_4; } else { AccessType _access_1 = attr.getAccess(); boolean _equals_1 = Objects.equal(_access_1, AccessType.READ); if (_equals_1) { String _plus_5 = (notebook + "ATTR "); String _plus_6 = (_plus_5 + "\\\""); String _name_1 = attr.getName(); String _plus_7 = (_plus_6 + _name_1); String _plus_8 = (_plus_7 + "\\\""); String _plus_9 = (_plus_8 + " write-protected"); String _plus_10 = (_plus_9 + "\n"); notebook = _plus_10; } else { String _plus_11 = (notebook + "#"); String _plus_12 = (_plus_11 + "ATTR "); String _plus_13 = (_plus_12 + "\\\""); String _name_2 = attr.getName(); String _plus_14 = (_plus_13 + _name_2); String _plus_15 = (_plus_14 + "\\\""); String _plus_16 = (_plus_15 + "\n"); notebook = _plus_16; } } } } return notebook; }