Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.cloudsearchdomain.model;
 

Information about a document that matches the search request.

 
 public class Hit implements SerializableCloneable {

    
The document ID of a document that matches the search request.
 
     private String id;

    
The fields returned from a document that matches the search request.
 
     private java.util.Map<String,java.util.List<String>> fields;

    
The highlights returned from a document that matches the search request.
 
     private java.util.Map<String,Stringhighlights;

    
The document ID of a document that matches the search request.

Returns:
The document ID of a document that matches the search request.
 
     public String getId() {
         return ;
     }
    
    
The document ID of a document that matches the search request.

Parameters:
id The document ID of a document that matches the search request.
 
     public void setId(String id) {
         this. = id;
     }
    
    
The document ID of a document that matches the search request.

Returns a reference to this object so that method calls can be chained together.

Parameters:
id The document ID of a document that matches the search request.
Returns:
A reference to this updated object so that method calls can be chained together.
 
     public Hit withId(String id) {
         this. = id;
         return this;
     }

    
The fields returned from a document that matches the search request.

Returns:
The fields returned from a document that matches the search request.
 
     public java.util.Map<String,java.util.List<String>> getFields() {
         
         if ( == null) {
              = new java.util.HashMap<String,java.util.List<String>>();
         }
         return ;
     }
    
    
The fields returned from a document that matches the search request.

Parameters:
fields The fields returned from a document that matches the search request.
 
     public void setFields(java.util.Map<String,java.util.List<String>> fields) {
         this. = fields;
     }
    
    
The fields returned from a document that matches the search request.

Returns a reference to this object so that method calls can be chained together.

Parameters:
fields The fields returned from a document that matches the search request.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Hit withFields(java.util.Map<String,java.util.List<String>> fields) {
        setFields(fields);
        return this;
    }

    
The fields returned from a document that matches the search request.

The method adds a new key-value pair into Fields parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into Fields.
value The corresponding value of the entry to be added into Fields.
  public Hit addFieldsEntry(String keyjava.util.List<Stringvalue) {
    if (null == this.) {
      this. = new java.util.HashMap<String,java.util.List<String>>();
    }
    if (this..containsKey(key))
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into Fields.

Returns a reference to this object so that method calls can be chained together.

  public Hit clearFieldsEntries() {
    this. = null;
    return this;
  }
  
    
The highlights returned from a document that matches the search request.

Returns:
The highlights returned from a document that matches the search request.
    public java.util.Map<String,StringgetHighlights() {
        
        if ( == null) {
             = new java.util.HashMap<String,String>();
        }
        return ;
    }
    
    
The highlights returned from a document that matches the search request.

Parameters:
highlights The highlights returned from a document that matches the search request.
    public void setHighlights(java.util.Map<String,Stringhighlights) {
        this. = highlights;
    }
    
    
The highlights returned from a document that matches the search request.

Returns a reference to this object so that method calls can be chained together.

Parameters:
highlights The highlights returned from a document that matches the search request.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Hit withHighlights(java.util.Map<String,Stringhighlights) {
        setHighlights(highlights);
        return this;
    }

    
The highlights returned from a document that matches the search request.

The method adds a new key-value pair into Highlights parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into Highlights.
value The corresponding value of the entry to be added into Highlights.
  public Hit addHighlightsEntry(String keyString value) {
    if (null == this.) {
      this. = new java.util.HashMap<String,String>();
    }
    if (this..containsKey(key))
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into Highlights.

Returns a reference to this object so that method calls can be chained together.

  public Hit clearHighlightsEntries() {
    this. = null;
    return this;
  }
  
    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getId() != nullsb.append("Id: " + getId() + ",");
        if (getFields() != nullsb.append("Fields: " + getFields() + ",");
        if (getHighlights() != nullsb.append("Highlights: " + getHighlights() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getId() == null) ? 0 : getId().hashCode()); 
        hashCode = prime * hashCode + ((getFields() == null) ? 0 : getFields().hashCode()); 
        hashCode = prime * hashCode + ((getHighlights() == null) ? 0 : getHighlights().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof Hit == falsereturn false;
        Hit other = (Hit)obj;
        
        if (other.getId() == null ^ this.getId() == nullreturn false;
        if (other.getId() != null && other.getId().equals(this.getId()) == falsereturn false
        if (other.getFields() == null ^ this.getFields() == nullreturn false;
        if (other.getFields() != null && other.getFields().equals(this.getFields()) == falsereturn false
        if (other.getHighlights() == null ^ this.getHighlights() == nullreturn false;
        if (other.getHighlights() != null && other.getHighlights().equals(this.getHighlights()) == falsereturn false
        return true;
    }
    
    @Override
    public Hit clone() {
        try {
            return (Hitsuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X