app/src/main/java/cl/ucn/disc/dsm/thenews/services/Transformer.java
public static Noticia transform(final Article article) {

    // Nullity
    if (article == null) {
      throw new NewsapiException("Article was null");
    }

    // The host
    final String host = getHost(article.url);

    // Si el articulo es null ..
    if (article.title == null) {

      log.warn("Article without title: {}", toString(article));

      // .. y el contenido es null, lanzar exception!
      if (article.description == null) {
        throw new NewsapiException("Article without title and description");
      }

      // FIXME: Cambiar el titulo por alguna informacion disponible
      article.title = "No Title*";
    }

    // FIXED: En caso de no haber una fuente.
    if (article.source == null) {
      article.source = new Source();

      if (host != null) {
        article.source.name = host;
      } else {
        article.source.name = "No Source*";
        log.warn("Article without source: {}", toString(article));
      }
    }

    // FIXED: Si el articulo no tiene author
    if (article.author == null) {

      if (host != null) {
        article.author = host;
      } else {
        article.author = "No Author*";
        log.warn("Article without author: {}", toString(article));
      }
    }

    // The date.
    final ZonedDateTime publishedAt = parseZonedDateTime(article.publishedAt)
        .withZoneSameInstant(Noticia.ZONE_ID);

    // The unique id (computed from hash)
    final Long theId = LongHashFunction.xx()
        .hashChars(article.title + article.source.name);

    // The Noticia.
    return new Noticia(
        theId,
        article.title,
        article.source.name,
        article.author,
        article.url,
        article.urlToImage,
        article.description,
        article.content,
        publishedAt
    );


  }
/**
   * Article to Noticia.
   *
   * @param article to transform
   * @return the Noticia.
   */
Article to Noticia.
@param article to transform
@return the Noticia.
Article to Noticia . @param article to transform @return the Noticia .
public static Noticia transform(final Article article) {
    if (article == null) {
      throw new NewsapiException("Article was null");
    }
    final String host = getHost(article.url);
    if (article.title == null) {
      log.warn("Article without title: {}", toString(article));
      if (article.description == null) {
        throw new NewsapiException("Article without title and description");
      }
      article.title = "No Title*";
    }
    if (article.source == null) {
      article.source = new Source();
      if (host != null) {
        article.source.name = host;
      } else {
        article.source.name = "No Source*";
        log.warn("Article without source: {}", toString(article));
      }
    }
    if (article.author == null) {
      if (host != null) {
        article.author = host;
      } else {
        article.author = "No Author*";
        log.warn("Article without author: {}", toString(article));
      }
    }
    final ZonedDateTime publishedAt = parseZonedDateTime(article.publishedAt)
        .withZoneSameInstant(Noticia.ZONE_ID);
    final Long theId = LongHashFunction.xx()
        .hashChars(article.title + article.source.name);
    return new Noticia(
        theId,
        article.title,
        article.source.name,
        article.author,
        article.url,
        article.urlToImage,
        article.description,
        article.content,
        publishedAt
    );
  }
public static Noticia transform ( final Article article ) { if ( article == null ) { throw new NewsapiException ( "Article was null" ) ; } final String host = getHost ( article . url ) ; if ( article . title == null ) { log . warn ( "Article without title: {}" , toString ( article ) ) ; if ( article . description == null ) { throw new NewsapiException ( "Article without title and description" ) ; } article . title = "No Title*" ; } if ( article . source == null ) { article . source = new Source ( ) ; if ( host != null ) { article . source . name = host ; } else { article . source . name = "No Source*" ; log . warn ( "Article without source: {}" , toString ( article ) ) ; } } if ( article . author == null ) { if ( host != null ) { article . author = host ; } else { article . author = "No Author*" ; log . warn ( "Article without author: {}" , toString ( article ) ) ; } } final ZonedDateTime publishedAt = parseZonedDateTime ( article . publishedAt ) . withZoneSameInstant ( Noticia . ZONE_ID ) ; final Long theId = LongHashFunction . xx ( ) . hashChars ( article . title + article . source . name ) ; return new Noticia ( theId , article . title , article . source . name , article . author , article . url , article . urlToImage , article . description , article . content , publishedAt ) ; }
Article to Noticia.
Article to Noticia .
// Nullity // The host // Si el articulo es null .. // .. y el contenido es null, lanzar exception! // FIXME: Cambiar el titulo por alguna informacion disponible // FIXED: En caso de no haber una fuente. // FIXED: Si el articulo no tiene author // The date. // The unique id (computed from hash) // The Noticia.