In Cypher you would create a label based constraint on the label :Person
and the property name
like this.
CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE;
In the Java API it is
try (Transaction tx = db.beginTx()) {
db.schema().constraintFor(DynamicLabel.label("Person")).assertPropertyIsUnique("name").create();
tx.success();
}