• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 Square, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.squareup.okhttp.internal.framed.hpackjson;
17 
18 import java.util.ArrayList;
19 import java.util.List;
20 
21 /**
22  * Representation of one story, a set of request headers to encode or decode.
23  * This class is used reflectively with Gson to parse stories from files.
24  */
25 public class Story implements Cloneable {
26 
27   private transient String fileName;
28   private List<Case> cases;
29   private int draft;
30   private String description;
31 
32   /**
33    * The filename is only used in the toString representation.
34    */
setFileName(String fileName)35   void setFileName(String fileName) {
36     this.fileName = fileName;
37   }
38 
getCases()39   public List<Case> getCases() {
40     return cases;
41   }
42 
43   /** We only expect stories that match the draft we've implemented to pass. */
getDraft()44   public int getDraft() {
45     return draft;
46   }
47 
48   @Override
clone()49   public Story clone() throws CloneNotSupportedException {
50     Story story = new Story();
51     story.fileName = this.fileName;
52     story.cases = new ArrayList<>();
53     for (Case caze : cases) {
54       story.cases.add(caze.clone());
55     }
56     story.draft = draft;
57     story.description = description;
58     return story;
59   }
60 
61   @Override
toString()62   public String toString() {
63     // Used as the test name.
64     return fileName;
65   }
66 }
67