*
* 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/eplv10.html
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.yangtools.yang.model.repo.api;
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.io.ByteSource;
-
import java.io.IOException;
import java.io.InputStream;
-
import org.opendaylight.yangtools.concepts.Delegator;
/**
* YANG text schema source representation. Exposes an RFC6020 text representation
* as an {@link InputStream}.
*/
+@Beta
public abstract class YangTextSchemaSource extends ByteSource implements SchemaSourceRepresentation {
private final SourceIdentifier identifier;
this.identifier = Preconditions.checkNotNull(identifier);
}
+ public static SourceIdentifier identifierFromFilename(final String name) {
+ checkArgument(name.endsWith(".yang"), "Filename %s does not have a .yang extension", name);
+ // FIXME: add revision-awareness
+ return SourceIdentifier.create(name.substring(0, name.length() - 5), Optional.<String>absent());
+ }
+
/**
* {@inheritDoc}
*/
@Override
public final String toString() {
- return addToStringAttributes(Objects.toStringHelper(this).add("identifier", identifier)).toString();
+ return addToStringAttributes(MoreObjects.toStringHelper(this).add("identifier", identifier)).toString();
}
/**
}
@Override
- public final ByteSource getDelegate() {
+ public ByteSource getDelegate() {
return delegate;
}