Repository: jenkinsci/jenkins
File: core/src/main/java/hudson/model/Result.java (Java)

Code before:
    public boolean isBetterThan(@NonNull Result that) {
        return this.ordinal < that.ordinal;
    }

    public boolean isBetterOrEqualTo(@NonNull Result that) {
        return this.ordinal <= that.ordinal;
    }

    /**
     * Is this a complete build - i.e. did it run to the end (not aborted)?
     * @since 1.526
     */
    public boolean isCompleteBuild() {
        return this.completeBuild;
    }

    @Override
    public @NonNull String toString() {
        return name;
    }

    @Override
    public @NonNull String toExportedObject() {
        return name;
    }

    public static @NonNull Result fromString(String s) {
         if (s == null) return FAILURE;
        for (Result r : all)
            if (s.equalsIgnoreCase(r.name))
                return r;
        return FAILURE;
    }

    private static @NonNull List<String> getNames() {
        List<String> l = new ArrayList<>();
        for (Result r : all)
            l.add(r.name);
        return l;
    }

    // Maintain each Result as a singleton deserialized (like build result from an agent node)
    private Object readResolve() {
        for (Result r : all)
            if (ordinal == r.ordinal)
                return r;
        return FAILURE;
    }

    private static final long serialVersionUID = 1L;


Review comment (bug):
Missing JavaDoc documentation for the `fromString` method. The method should document:
1. The purpose of the method (converting a string to a Result enum)
2. The parameter `s` - what it represents and that it can now be null
3. The return value - what Result is returned for various inputs
4. The behavior when `s` is null (returns `FAILURE`)
5. The behavior when `s` doesn't match any known result (returns `FAILURE`)

Example:
```java
/**
 * Converts a string to a Result.
 * 
 * @param s the result name to convert, may be null
 * @return the matching Result, or FAILURE if s is null or doesn't match any known result name
 */
```
```suggestion

    /**
     * Converts a string to a {@link Result}.
     *
     * @param s the result name to convert, may be {@code null}
     * @return the matching {@link Result}, or {@link #FAILURE} if {@code s} is {@code null} or doesn't match any known result name
     */
```

Code after:
    public boolean isBetterThan(@NonNull Result that) {
        return this.ordinal < that.ordinal;
    }

    public boolean isBetterOrEqualTo(@NonNull Result that) {
        return this.ordinal <= that.ordinal;
    }

    /**
     * Is this a complete build - i.e. did it run to the end (not aborted)?
     * @since 1.526
     */
    public boolean isCompleteBuild() {
        return this.completeBuild;
    }

    @Override
    public @NonNull String toString() {
        return name;
    }

    @Override
    public @NonNull String toExportedObject() {
        return name;
    }

    public static @NonNull Result fromString(@NonNull String s) {
        for (Result r : all)
            if (s.equalsIgnoreCase(r.name))
                return r;
        return FAILURE;
    }

    private static @NonNull List<String> getNames() {
        List<String> l = new ArrayList<>();
        for (Result r : all)
            l.add(r.name);
        return l;
    }

    // Maintain each Result as a singleton deserialized (like build result from an agent node)
    private Object readResolve() {
        for (Result r : all)
            if (ordinal == r.ordinal)
                return r;
        return FAILURE;
    }

    private static final long serialVersionUID = 1L;

    private static final Result[] all = new Result[] {SUCCESS, UNSTABLE, FAILURE, NOT_BUILT, ABORTED};