Skip to main content
Remove spaces in front of {@code and {@literal to compensate inner spaces
Source Link
leventov
  • 15.5k
  • 11
  • 74
  • 104

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket
  • remove one space in front of {@code and {@literal, to compensate inner spaces and keep the alignment

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new Translator{@code <StringTranslator<String, Integer>}(String.class, Integer.class){ *  {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * </pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new Translator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new Translator{@code <String, Integer>}(String.class, Integer.class){ *  {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * </pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new Translator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket
  • remove one space in front of {@code and {@literal, to compensate inner spaces and keep the alignment

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new{@code Translator<String, Integer>}(String.class, Integer.class){ * {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * </pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new Translator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 
added 1 characters in body
Source Link
Christoph Naber
  • 1.9k
  • 1
  • 11
  • 3

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new Translator{@code <String, Integer>}(String.class, Integer.class){ * {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * <pre></pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new Translator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new Translator{@code <String, Integer>}(String.class, Integer.class){ * {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * <pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new Translator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new Translator{@code <String, Integer>}(String.class, Integer.class){ * {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * </pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new Translator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 
deleted 13 characters in body
Source Link
Christoph Naber
  • 1.9k
  • 1
  • 11
  • 3

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new Translator{@code <String, Integer>}(String.class, Integer.class){ * {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * <pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new AbstractClassTranslator<StringTranslator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new Translator{@code <String, Integer>}(String.class, Integer.class){ * {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * <pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new AbstractClassTranslator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 

I had a really tough time with including a specific code example in a javadoc comment. I'd like to share this one.
Please note the following:

  • usage of old <code> - tag to prevent the curly brackets from being interpreted
  • usage of "new" {@code ...} - tag to get the generics included in the output
  • escaping of the @ sign in @Override via "{@literal @}Override" because javadoc generator "tilts" there due to the fact that the @ goes directly after an opening curly bracket

javadoc code:

/** this methods adds a specific translator from one type to another type. ` * i.e. * <pre> * <code>new BeanTranslator.Builder() * .translate( * new Translator{@code <String, Integer>}(String.class, Integer.class){ * {@literal @}Override * public Integer translate(String instance) { * return Integer.valueOf(instance); * }}) * .build(); * </code> * <pre> * @param translator */ 

gets printed as

new BeanTranslator.Builder() .translate( new Translator<String, Integer>(String.class, Integer.class){ @Override public Integer translate(String instance) { return Integer.valueOf(instance); }}) .build(); 
Source Link
Christoph Naber
  • 1.9k
  • 1
  • 11
  • 3
Loading