/** * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.mdsal.binding.testutils; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; import org.opendaylight.yangtools.concepts.Builder; /** * Xtend extension method for >> operator support for {@link Builder}s. * *
import static extension org.opendaylight.mdsal.binding.testutils * .XtendBuilderExtensions.operator_doubleGreaterThan* *
allows to write (in an *.xtend, not *.java): * *
new InterfaceBuilder >> [ * name = "hello, world" * ]* *
instead of: * *
(new InterfaceBuilder => [ * name = "hello, world" * ]).build* *
See also org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_doubleArrow for background. * * @author Michael Vorburger */ public final class XtendBuilderExtensions { private XtendBuilderExtensions() { } public static
> P operator_doubleGreaterThan( final T object, final Procedure1 super T> block) { block.apply(object); return object.build(); } }