All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swrlapi.drools.converters.oo.DroolsOWLIndividual2IConverter Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package org.swrlapi.drools.converters.oo;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLIndividual;
import org.swrlapi.bridge.SWRLRuleEngineBridge;
import org.swrlapi.bridge.converters.TargetRuleEngineConverterBase;
import org.swrlapi.bridge.converters.TargetRuleEngineOWLIndividualConverter;
import org.swrlapi.drools.owl.individuals.I;

/**
 * Converts an OWLAPI OWL individual to a Drools individual represented by the class
 * {@link I}.
 *
 * @see org.semanticweb.owlapi.model.OWLIndividual
 * @see org.semanticweb.owlapi.model.OWLAnonymousIndividual
 * @see org.semanticweb.owlapi.model.OWLNamedIndividual
 * @see I
 */
public class DroolsOWLIndividual2IConverter extends TargetRuleEngineConverterBase
    implements TargetRuleEngineOWLIndividualConverter
{
  public DroolsOWLIndividual2IConverter(@NonNull SWRLRuleEngineBridge bridge)
  {
    super(bridge);
  }

  @NonNull @Override public I convert(@NonNull OWLIndividual individual)
  {
    if (individual.isNamed()) {
      IRI individualIRI = individual.asOWLNamedIndividual().getIRI();
      String individualPrefixedName = iri2PrefixedName(individualIRI);
      return new I(individualPrefixedName);
    } else
      return new I(individual.asOWLAnonymousIndividual().getID().getID());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy