Browse Source

DATAMONGO-2067 - Polishing.

Tweak Javadoc and reference docs. Use pre/class=code instead of nested code tag.

Original pull request: #756.
pull/758/head
Mark Paluch 7 years ago
parent
commit
7a22d697cf
  1. 24
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndex.java
  2. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndexes.java
  3. 6
      src/main/asciidoc/reference/mapping.adoc

24
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndex.java

@ -25,13 +25,11 @@ import java.lang.annotation.Target;
/** /**
* Mark a class to use compound indexes. * Mark a class to use compound indexes.
* <p /> * <p />
* Some situations may require to have more than one {@link CompoundIndex}. For those scenarios {@link CompoundIndexes} * <p>
* functions as container annotation for multiple {@link CompoundIndex} annotations via the * <b>NOTE: This annotation is repeatable according to Java 8 conventions using {@link CompoundIndexes#value()} as
* {@link CompoundIndexes#value()} or by repeating the {@link CompoundIndex} on the class itself. * container.</b>
*
* <pre>
* <code>
* *
* <pre class="code">
* &#64;Document * &#64;Document
* &#64;CompoundIndex(def = "{'firstname': 1, 'lastname': 1}") * &#64;CompoundIndex(def = "{'firstname': 1, 'lastname': 1}")
* &#64;CompoundIndex(def = "{'address.city': 1, 'address.street': 1}") * &#64;CompoundIndex(def = "{'address.city': 1, 'address.street': 1}")
@ -41,7 +39,6 @@ import java.lang.annotation.Target;
* *
* Address address; * Address address;
* } * }
* </code>
* </pre> * </pre>
* *
* @author Jon Brisbin * @author Jon Brisbin
@ -63,9 +60,7 @@ public @interface CompoundIndex {
* <br /> * <br />
* If left empty on nested document, the whole document will be indexed. * If left empty on nested document, the whole document will be indexed.
* *
* <pre> * <pre class="code">
* <code>
*
* &#64;Document * &#64;Document
* &#64;CompoundIndex(def = "{'h1': 1, 'h2': 1}") * &#64;CompoundIndex(def = "{'h1': 1, 'h2': 1}")
* class JsonStringIndexDefinition { * class JsonStringIndexDefinition {
@ -77,7 +72,6 @@ public @interface CompoundIndex {
* class ExpressionIndexDefinition { * class ExpressionIndexDefinition {
* String h1, h2; * String h1, h2;
* } * }
* </code>
* </pre> * </pre>
* *
* @return * @return
@ -127,8 +121,7 @@ public @interface CompoundIndex {
* <br /> * <br />
* The structure below * The structure below
* *
* <pre> * <pre class="code">
* <code>
* &#64;Document * &#64;Document
* class Root { * class Root {
* Hybrid hybrid; * Hybrid hybrid;
@ -145,17 +138,14 @@ public @interface CompoundIndex {
* class Nested { * class Nested {
* String n1, n2; * String n1, n2;
* } * }
* </code>
* </pre> * </pre>
* *
* resolves in the following index structures * resolves in the following index structures
* *
* <pre> * <pre class="code">
* <code>
* db.root.createIndex( { hybrid.h1: 1, hybrid.h2: 1 } , { name: "hybrid.compound_index" } ) * db.root.createIndex( { hybrid.h1: 1, hybrid.h2: 1 } , { name: "hybrid.compound_index" } )
* db.root.createIndex( { nested.n1: 1, nested.n2: 1 } , { name: "nested.compound_index" } ) * db.root.createIndex( { nested.n1: 1, nested.n2: 1 } , { name: "nested.compound_index" } )
* db.hybrid.createIndex( { h1: 1, h2: 1 } , { name: "compound_index" } ) * db.hybrid.createIndex( { h1: 1, h2: 1 } , { name: "compound_index" } )
* </code>
* </pre> * </pre>
* *
* @return * @return

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndexes.java

@ -23,6 +23,10 @@ import java.lang.annotation.Target;
/** /**
* Container annotation that allows to collect multiple {@link CompoundIndex} annotations. * Container annotation that allows to collect multiple {@link CompoundIndex} annotations.
* <p>
* Can be used natively, declaring several nested {@link CompoundIndex} annotations. Can also be used in conjunction
* with Java 8's support for <em>repeatable annotations</em>, where {@link CompoundIndex} can simply be declared several
* times on the same {@linkplain ElementType#TYPE type}, implicitly generating this container annotation.
* *
* @author Jon Brisbin * @author Jon Brisbin
* @author Christoph Strobl * @author Christoph Strobl

6
src/main/asciidoc/reference/mapping.adoc

@ -428,9 +428,7 @@ Here is an example of a more complex mapping.
[source,java] [source,java]
---- ----
@Document @Document
@CompoundIndexes({
@CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}") @CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}")
})
public class Person<T extends Address> { public class Person<T extends Address> {
@Id @Id
@ -570,9 +568,7 @@ Here's an example that creates a compound index of `lastName` in ascending order
package com.mycompany.domain; package com.mycompany.domain;
@Document @Document
@CompoundIndexes({
@CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}") @CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}")
})
public class Person { public class Person {
@Id @Id
@ -587,7 +583,7 @@ public class Person {
[TIP] [TIP]
==== ====
`@CompoundIndex` is a repeatable annotation using `@CompoundIndexes` as the container. `@CompoundIndex` is repeatable using `@CompoundIndexes` as its container.
[source,java] [source,java]
---- ----

Loading…
Cancel
Save