Java Code Examples for com.igormaznitsa.meta.common.utils.Assertions#assertNotNull()

The following examples show how to use com.igormaznitsa.meta.common.utils.Assertions#assertNotNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Topic.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
public void setText(@Nonnull final String text) {
  this.map.lock();
  try {
    this.text = Assertions.assertNotNull(text);
  } finally {
    this.map.unlock();
  }
}
 
Example 2
Source File: Topic.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
private Topic(@Nonnull final MindMap map, @Nonnull final String text, @Nonnull @MayContainNull final Extra<?>... extras) {
  this.map = Assertions.assertNotNull(map);
  this.text = Assertions.assertNotNull(text);

  for (final Extra<?> e : extras) {
    if (e != null) {
      this.extras.put(e.getType(), e);
    }
  }
}
 
Example 3
Source File: MindMapPanel.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Nonnull
public MindMap getModel() {
  this.lock();
  try {
    return Assertions.assertNotNull("Model is not provided, it must not be null!", this.model);
  } finally {
    this.unlock();
  }
}
 
Example 4
Source File: SortedTreeModelWrapper.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public Object getRoot() {
  return Assertions.assertNotNull(this.model.getRoot());
}
 
Example 5
Source File: JBBPScriptTranslator.java    From java-binary-block-parser with Apache License 2.0 4 votes vote down vote up
@Nonnull
public Parameters setEncodingOut(@Nullable final String text) {
  this.outEncoding = Assertions.assertNotNull(text);
  return this;
}
 
Example 6
Source File: MindMapModelEvent.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
public MindMapModelEvent(@Nonnull final MindMap source, @Nullable @MustNotContainNull final Topic[] path) {
  this.source = Assertions.assertNotNull(source);
  this.path = path == null ? EMPTY : path.clone();
}
 
Example 7
Source File: JBBPScriptTranslator.java    From java-binary-block-parser with Apache License 2.0 4 votes vote down vote up
@Nonnull
public Parameters setEncodingIn(@Nullable final String text) {
  this.inEncoding = Assertions.assertNotNull(text);
  return this;
}
 
Example 8
Source File: TextBlock.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
public TextBlock(@Nonnull final String text, @Nonnull final TextAlign justify) {
  updateText(Assertions.assertNotNull(text));
  this.textAlign = Assertions.assertNotNull(justify);
}
 
Example 9
Source File: Pair.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
public Pair(@Nonnull final L left, @Nonnull final R right) {
  this.left = Assertions.assertNotNull(left);
  this.right = Assertions.assertNotNull(right);
}
 
Example 10
Source File: GoMod.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
public ModuleInfo(@Nonnull final String name) {
    this.name = Assertions.assertNotNull(name);
    this.version = null;
}
 
Example 11
Source File: GolangModMojo.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
@Nonnull
@MustNotContainNull
@Override
public String[] getCommandFlags() {
  return new String[]{Assertions.assertNotNull(this.command)};
}
 
Example 12
Source File: PackageList.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
public Package(@Nonnull final String pkg, @Nullable final String branch, @Nullable final String tag, @Nullable final String revision) {
  this.pkg = Assertions.assertNotNull(pkg);
  this.branch = branch;
  this.revision = revision;
  this.tag = tag;
}
 
Example 13
Source File: Tuple.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
private Tuple(@Nonnull final A left, @Nonnull final B right) {
  this.left = Assertions.assertNotNull(left);
  this.right = Assertions.assertNotNull(right);
}
 
Example 14
Source File: JavaConverter.java    From java-binary-block-parser with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public Set<File> translate(@Nonnull final Parameters parameters, final boolean dryRun) throws IOException {
  final String text;
  final String rawFileName;
  if (parameters.getScriptFile() == null) {
    rawFileName = parameters.getDestFileName() == null ? "JbbpNoName" : parameters.getDestFileName();
    text = Assertions.assertNotNull("Script file is null, expected script text", parameters.getScriptText());
  } else {
    final File scriptToProcess = parameters.getScriptFile();
    rawFileName = FilenameUtils.getBaseName(scriptToProcess.getName());
    text = FileUtils.readFileToString(scriptToProcess, parameters.getEncodingIn());
  }
  final String className = CommonUtils.extractClassName(rawFileName);
  final String packageName = parameters.getPackageName() == null ? CommonUtils.extractPackageName(rawFileName) : parameters.getPackageName();

  final Set<File> resultFiles = Collections.singleton(CommonUtils.scriptFileToJavaFile(parameters.getOutputDir(), parameters.getPackageName(), parameters.getScriptFile()));
  if (!dryRun) {

    final File resultJavaFile = resultFiles.iterator().next();

    final JBBPParser parser = JBBPParser.prepare(text, JBBPBitOrder.LSB0, parameters.customFieldTypeProcessor, parameters.getParserFlags());

    final String[] implementsSorted = parameters.getClassImplements().toArray(ARRAY_STRING_EMPTY);
    Arrays.sort(implementsSorted);

    final JBBPToJavaConverter.Builder builder = JBBPToJavaConverter.makeBuilder(parser)
        .setMapSubClassesInterfaces(parameters.getSubClassInterfaces())
        .setMapSubClassesSuperclasses(parameters.getSubClassSuperclasses())
        .setMainClassName(className)
        .setHeadComment(parameters.getHeadComment())
        .setMainClassPackage(packageName)
        .setMainClassCustomText(parameters.getCustomText())
        .setAddGettersSetters(parameters.isAddGettersSetters())
        .setDoMainClassAbstract(parameters.isDoAbstract())
        .setMainClassImplements(implementsSorted)
        .setParserFlags(parameters.getParserFlags())
        .setSuperClass(parameters.getSuperClass());

    if (parameters.isAddBinAnnotations()) {
      builder.addBinAnnotations();
    }

    if (parameters.isAddNewInstanceMethods()) {
      builder.addNewInstanceMethods();
    }

    if (parameters.isDoInternalClassesNonStatic()) {
      builder.doInternalClassesNonStatic();
    }

    if (parameters.isDisableGenerateFields()) {
      builder.disableGenerateFields();
    }

    FileUtils.write(resultJavaFile, builder.build().convert(), parameters.getEncodingOut());
  }
  return resultFiles;
}
 
Example 15
Source File: GoMod.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
public GoReplace(@Nonnull final ModuleInfo module, @Nonnull final ModuleInfo replacement) {
    this.module = Assertions.assertNotNull(module);
    this.replacement = Assertions.assertNotNull(replacement);
}
 
Example 16
Source File: JBBPScriptTranslator.java    From java-binary-block-parser with Apache License 2.0 4 votes vote down vote up
@Nonnull
public Parameters setScriptText(@Nonnull final String text) {
  this.scriptText = Assertions.assertNotNull(text);
  return this;
}
 
Example 17
Source File: GoMod.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
public GoRequire(@Nonnull final ModuleInfo moduleInfo) {
    this.moduleInfo = Assertions.assertNotNull(moduleInfo);
}
 
Example 18
Source File: GoMod.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
public GoModule(@Nonnull final ModuleInfo module) {
    this.moduleInfo = Assertions.assertNotNull(module);
}
 
Example 19
Source File: GoMod.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
public ModuleInfo(@Nonnull final String name, @Nullable final String version) {
    this.name = Assertions.assertNotNull(name);
    this.version = version;
}
 
Example 20
Source File: MMDPrintOptions.java    From netbeans-mmd-plugin with Apache License 2.0 2 votes vote down vote up
/**
 * Set the selected scale option.
 *
 * @param scaleOption option, must not be null
 * @return this instance
 */
@Nonnull
public MMDPrintOptions setScaleType(@Nonnull final ScaleType scaleOption) {
  this.scaleOption = Assertions.assertNotNull(scaleOption);
  return this;
}